Android ListView项目布局
我正在设计我的应用程序,但是我在设计ListView的项目时遇到了一些问题 很好,你可以找到它的样子,以及我想要的样子 这是项目的布局:Android ListView项目布局,android,android-layout,android-listview,android-fragments,Android,Android Layout,Android Listview,Android Fragments,我正在设计我的应用程序,但是我在设计ListView的项目时遇到了一些问题 很好,你可以找到它的样子,以及我想要的样子 这是项目的布局: <TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeight" >
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft"
android:layout_marginTop="8dip"
android:textAppearance="?android:attr/textAppearanceListItem"
/>
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true" >
<ImageView
android:id="@+id/favourite_status"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignTop="@android:id/text1"
android:src="@drawable/is_not_favourite"
android:contentDescription="@string/list_favorites_status"
android:background="@null"
android:layout_margin="9dp"/>
</RelativeLayout>
<TextView android:id="@android:id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/text1"
android:layout_alignLeft="@android:id/text1"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</TwoLineListItem>
问题在于文本:我不希望描述溢出到应该为空的空间中。
提前感谢您的帮助
简单,您可以执行以下操作:
<LinearLayout
....
android:orientation="horizontal"
....>
<LinearLayout
....
android:orientation="vertical"
....>
<TextView />
<TextView />
</LinearLayout>
<ImageView />
</LinearLayout>
这是一个基本布局,您也可以通过RelativeLayout实现同样的效果。您使用的是wrapContent而不是给定值。这只是正确构造布局的问题。在上面的布局中,你有一个文本视图,你的标题后面跟着一个相对物。你的图像基本上会向右浮动,然后你的最后一个文本视图,你的描述会占用所有剩余的空间。谢谢你的帮助。问题是我想在星号下留下空白,不要让文本溢出