How to dynamically change the background LinearLayout?
A:
Did you try one of these :
yourLayout.setBackgroundColor(int color);
yourLayout.setBackgroundDrawable(Drawable d);
yourLayout.setBackgroundResource(int resid);
and if does not refresh on its own, this should give it a boost :
yourLayout.invalidate();
Sephy
2010-08-18 13:57:39
Tried not once, not working
2010-08-18 14:13:28
A:
I'm at work right now, so I can't test this, but I believe this should work:
LinearLayout linLay = (LinearLayout) findViewById(R.id.theLinearLayoutId);
//set background to a color
linLay.setBackgroundColor("#404040");
//set background to a drawable
linLay.setBackgroundDrawable(drawableItem);
//set background to a resource
linLay.setBackgroundResource(R.id.backgroundResource);
I'll try to test this when I get home.
Edit: beaten by Sephy :P
kcoppock
2010-08-18 13:57:40
Bizon, from your comment, are you just trying to change to a different layout when the phone is switched to landscape mode versus portrait mode?If so, you should make a new layout.xml file, and place it under res/layout-land/http://developer.android.com/guide/topics/resources/index.html
kcoppock
2010-08-18 14:37:40