使ListView项目顶层布局LinearLayout具有“水平”方向。然后TextViews将并排。
您也可以使用 aRelativeLayout然后轻松地将每个放置TextView在任何位置。
默认ListView布局android.R.layout.simple_list_item_2如下所示:
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:mode="twoLine"
android:paddingBottom="9dp"
android:paddingTop="5dp" >
<TextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceListItem" />
<TextView
android:id="@android:id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/text1"
android:layout_below="@android:id/text1"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TwoLineListItem>
从这个开始。
要使用“水平” LinearLayout,您必须用“ ”将其更改TwoLineListItem为并添加额外的.
要使用 a您必须更改into ,添加附加,然后根据需要放置它们。LinearLayoutandroid:orientation="horizontalTextView
RelativeLayoutTwoLineListItemRelativeLayoutTextView