【发布时间】:2013-09-30 07:14:36
【问题描述】:
我有一个包含三列的列表视图。第一个是 ImageView,第二个和第三个是 textviews(见代码)。
我希望列表像这样对齐:
- 图标和日期应始终完整显示!!
- 中间的文本应显示尽可能多的字符
- 日期应始终在右侧
下面的 XML 在我的 Nexus 4 上看起来不错。但在华硕平板电脑上,日期应该更多在右侧,中间的列应该显示更多文本 (screenshot 1)。在 AVD (screenshot 2) 上,中间的列应该更小,日期应该完整显示。
谁能告诉我如何更改 XML?谢谢!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
<ImageView
android:id="@+id/logo"
android:layout_width="50px"
android:layout_height="50px"
android:layout_marginLeft="5px"
android:layout_marginRight="20px"
android:layout_marginTop="5px"
android:src="@drawable/social_chat"
android:layout_weight="0"
>
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_marginTop="0px"
android:text="@+id/label"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="50"
android:maxLines="1"
android:singleLine="true"
>
</TextView>
<TextView
android:id="@+id/last_changed"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_marginTop="15px"
android:layout_marginLeft="5px"
android:text="@+id/last_changed"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="50"
android:maxLines="1"
android:singleLine="true"
>
</TextView>
【问题讨论】:
-
这是我的 nexus 4 的屏幕截图。看起来不错。 abload.de/img/nexus40vkzt.png
-
第一件事,不要使用“px”..使用“dp”
标签: android android-layout listview android-listview alignment