2013-04-22 117 views
1

我有一個線性佈局,我將添加視圖使其像列表一樣,(不使用android列表視圖的原因是,我在我的滑動滾動視圖中使用此佈局菜單,並知道列表視圖不能直接在滾動視圖中使用)。我不知道我是否聽錯了或沒有,但我要的是滾動視圖和裏面,如下圖所示的供用戶選擇的選項滾動列表:Android - 添加視圖到佈局

enter image description here

我的滾動觀點看起來是這樣的:

<scrollview> 
    <main layout> 
     <some layout> 
     <some layout> 
     <some layout> 
     <some layout> ////i wanted a list view here. as listview cant be used directly inside 
          scrollview, i add views in the code to make it a list 
         like view which has image view and checkedtextview to make it look like a 
         list view 

    <main layout> 
<scrollview> 

現在的問題是增加一個觀點後,我還要補充分頻器分開兩個連續的意見。這是我的完整滾動layout.xml代碼http://pastebin.com/YZPj9w4C

這是我的佈局(list_item_category),我添加作爲單一視圖http://pastebin.com/htCTKmdT上述滾動layout.xml

這裏是我的代碼我用充氣一個查看佈局:

for (int i = 0; i < 9; i++) { 
      panelView = inflater.inflate(R.layout.dialog_list_item_category, 
        null, false); 
      panelView.setId(i); 

      final CheckedTextView chk = (CheckedTextView) panelView 
        .findViewById(R.id.categories_checkbox); 

      chk.setText(some text); 

      ImageView img = (ImageView) panelView 
        .findViewById(R.id.categories_icon); 

      img.setImageResource(some icon); 
} 

總之,在將每個視圖充滿布局之後,我需要一個分隔線。

任何想法該怎麼做?

+0

[鏈接](http://stackoverflow.com/questions/3979218/android-listview-divider),希望這有助於 – Sunny 2013-04-22 06:37:48

+0

@Sunny我認爲ü沒有正確理解我的問題,我不打擾如何爲列表視圖添加分隔線,我想手動添加分隔線視圖到佈局。 – 2013-04-22 06:41:46

回答

1

具有指定高度,寬度和顏色的TextView將起作用。嘗試添加這個,

<TextView 
android:layout_width="fill_parent" 
android:layout_height="5dp" 
android:background="#colorCode"  
/> 

TextView基本上就是這樣。如果需要,可以添加額外的屬性,但關鍵點是textview的高度,listview_divider應該相等,也是textview和listview分隔線的背景顏色。在ListView控件的分隔器高度和顏色,您可以使用

android:divider="#colorCode" 
android:dividerHeight="sameAsTextViewHeight" 
相關問題