我正在尝试让我的TextViews和ImageView显示在我添加了StateListDrawable的LinearLayout之上。我像这样创建我的按钮:
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;
}在我的活动中,我将这个可绘制内容添加到linearLayout中,如下所示:
_topMenuButton.setBackgroundDrawable(_theme.getPrimaryButtonDrawable());布局包含在我的活动的content视图中的以下行中:
<include layout="@layout/inc_button_menu" android:id="@+id/second_menu_button" />其又包括内部具有一个ImageView和两个TextViews的LinearLayout。
当我尝试从LinearLayout (我在我的活动中向其添加了StateListDrawable )获取TextViews并向其添加文本时,文本不会显示。ImageView也是如此。我不确定如何才能让这些视图显示出来。
任何帮助都是非常感谢的。
发布于 2013-07-20 15:59:01
事实证明,这不是代码背后的代码,而是包含布局中的代码。由于该代码以前在布局文件为可绘制的情况下工作,因此我假定它不是该代码。问题是我在其中一个项目上使用了android:weight="1“。
https://stackoverflow.com/questions/15821840
复制相似问题