首先是一些图片:
需要这个:
这个:
问题是蓝色矩形。在第一张图像中,它不是水平地填充整个片段,而在第二张图像中它是。知道如何做到这一点吗?
当然这里是代码:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_marginRight="20dp"
android:orientation="vertical">
<TextView
style="@style/item_channel.name"
android:layout_width="300dp"
android:layout_height="80dp"
android:background="#80161616"
android:cacheColorHint="#80161616"
android:textColor="@color/white"
android:text="@string/channel_list"/>
<ImageView
android:layout_gravity="center_horizontal"
android:layout_height="5dp"
android:layout_width="fill_parent"
android:background="@color/white"
android:src="@android:drawable/divider_horizontal_bright" />
<ListView
style="@style/list"
android:id="@+id/list_channels"/>
</LinearLayout>
</FrameLayout>
答案 0 :(得分:0)
您应该使用适配器来填充列表视图。然后你应该为每一行创建另一个xml。我的意思是,一个xml的earch行。在这个xml中,您可以使用margin和padding。它们会影响行。
答案 1 :(得分:0)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical">
<TextView
style="@style/item_channel.name"
android:layout_width="300dp"
android:layout_height="80dp"
android:background="#80161616"
android:cacheColorHint="#80161616"
android:textColor="@color/white"
android:text="@string/channel_list"/>
<ImageView
android:layout_gravity="center_horizontal"
android:layout_height="5dp"
android:layout_width="fill_parent"
android:background="@color/white"
android:src="@android:drawable/divider_horizontal_bright" />
<ListView
style="@style/list"
android:id="@+id/list_channels"/>
</LinearLayout>
</FrameLayout>
然后是你的listview风格:
<style name="list" parent="@android:style/Widget.ListView">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
我没有测试过代码,所以我错了。