I'm trying to get my TextViews and ImageView to show up on top of a LinearLayout which I added a StateListDrawable to. I create my buttons like this:
protected StateListDrawable generateButton(String[] colors, String[] selectColors, String strokeColor, int strokewidth)
{
int[] iColors = CurrentTheme.getIntColorArrayFromStringArray(colors);
GradientDrawable gd = new GradientDrawable(Orientation.TL_BR, iColors);
gd.setCornerRadius(10);
gd.setStroke(strokewidth, Color.parseColor(strokeColor));
int[] iSelectColors = CurrentTheme.getIntColorArrayFromStringArray(selectColors);
GradientDrawable sgd = new GradientDrawable(Orientation.TL_BR, iSelectColors);
sgd.setCornerRadius(10);
sgd.setStroke(strokewidth, Color.parseColor(strokeColor));
StateListDrawable slDrawable = new StateListDrawable();
slDrawable.addState(new int[] { android.R.attr.state_pressed }, sgd);
slDrawable.addState(StateSet.WILD_CARD, gd);
return slDrawable;
}
In my activity I add this drawable to a linearLayout like so:
_topMenuButton.setBackgroundDrawable(_theme.getPrimaryButtonDrawable());
The layout is included with the following line in the content view of my Activity:
<include layout="@layout/inc_button_menu" android:id="@+id/second_menu_button" />
Which in turn includes a LinearLayout which has a ImageView and two TextViews inside.
When I try to get the TextViews from the LinearLayout (which I added the StateListDrawable to in my Activity) and add Text to them the text doesn't show. Same goes for the ImageView. I'm not sure how I am able to get these Views to show up.
Any help is greatly appreciated.
It turned out that it wasn't the code behind but the code from the included layout. Since the code worked before with a layout file as drawable, I assumed that it wasn't this code. The problem was that I used android:weight="1" on one of the items.