2014-11-04 57 views
1

我想在我的布局中显示两个具有相同数量项目的ListView(并行垂直),但问题是它们的高度不同步。 所以我想使他们的高度等于...具有相同行高的两个垂直Listviews

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/parent_lf" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/aya_1" 
android:baselineAligned="false" 
android:orientation="horizontal" > 

<ListView 
    android:id="@+id/index" 
    android:layout_width="0dp" 
    android:layout_height="fill_parent" 
    android:layout_weight="0.15" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0sp" 
    android:fastScrollEnabled="true" /> 

<ListView 
    android:id="@+id/content" 
    android:layout_width="0dp" 
    android:layout_height="fill_parent" 
    android:layout_weight="0.85" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/darker_gray" 
    android:dividerHeight="0.2sp" 
    android:fastScrollEnabled="true" /> 

有任何想法请!

感谢所有

穆罕默德

+0

您的分频器的高度不等于让你列表视图不SYNCD一样。 – Dhina 2014-11-04 12:30:42

+0

您在列表视图中添加的单个项目是否具有相同的高度? – Rohit5k2 2014-11-04 12:35:22

+0

我加了分隔线,但是得到了同样的结果... – Mohamed 2014-11-04 12:37:46

回答

0

你可以写这样的代码,以平等的列表视图:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/parent_lf" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@android:color/black" 
android:baselineAligned="false" 
android:orientation="horizontal" 
android:weightSum="2" > 

<ListView 
    android:id="@+id/index" 
    android:layout_width="0dp" 
    android:layout_height="250dp" 
    android:layout_weight="1" 
    android:background="@android:color/white" 
    android:choiceMode="singleChoice" 

    android:divider="@android:color/transparent" 
    android:dividerHeight="0sp" 
    android:fastScrollEnabled="true" /> 

<ListView 
    android:id="@+id/content" 
    android:layout_width="0dp" 
    android:layout_height="250dp" 
    android:layout_weight="1" 
    android:background="@android:color/white" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/darker_gray" 
    android:dividerHeight="0.2sp" 
    android:fastScrollEnabled="true" /> 

+0

不,它没有解决问题:( – Mohamed 2014-11-04 13:21:13

+0

什么是你想要显示的问题这个列表视图是水平的,只是复制并粘贴它将会工作的代码 – 2014-11-04 13:27:28

+0

不,我只是希望列表1和列表2中每一行的高度匹配 – Mohamed 2014-11-04 13:38:50

相关问题