0
(Android app development question) How do I set the style resource of a LinearLayout in Java?
So I have a LinearLayout in my XML layout file and in my activity with an ID of "layout". In my Java Activity, I have a variable that is LinearLayout l = findViewById(R.id.layout). I want to add another LinearLayout to "l" using the "addView" method. I want the LinearLayout I am adding to "l" to have the style of a style in the "styles.xml" file. How do I do that?
1 Answer
+ 1
While constructing object of Linear Layout pass the Style reference as 3rd parameter:
`LinearLayout childOfL = new LinearLayout(this, null, R.style.myLinearLayoutStyle);`