我試圖設置一個分隔線用於我的應用程序的列表中。我已做好「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