我试图设置一个分隔线用于我的应用程序的列表中。我已做好“dicedivider”的XML代码如下图所示Android LinearLayout:分隔线不会显示
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1px"
android:color="@color/divider_Color"
/>
</shape>
然后我试图将其设置为分频器绘制了我的LinearLayout如下图所示
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
diceCount = 0;
diceList = (LinearLayout) this.findViewById(R.id.main_Dice_List);
diceList.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
diceList.setDividerDrawable(this.getResources().getDrawable(R.drawable.dicedivider));
diceList.setDividerPadding(5);
addDice();
}
不管这虽然应用程序显示没有分隔符。我甚至试图直接将它嵌入到XML中,并没有任何运气。
我很新的Android编码。任何想法,我要去哪里错了?
见例如代码[* *这里**] [1],我也支持旧设备。 [1]:http://stackoverflow.com/questions/22547897/how-to-add-dividers-to-linearlayoutics/ –
**不要忘记**的'机器人:showDividers'项! – Fattie