【发布时间】:2014-12-10 23:43:39
【问题描述】:
我想在 Material Design page 中实现此处显示的两行列表项。
首先是我的xml文件,它表示要在适配器中使用的列表项:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="72dp" >
<TextView
android:text="Artist"
android:textSize="16sp"
android:typeface="sans"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:id="@+id/textView_artist_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:text="10 Albumnes"
android:textSize="14sp"
android:typeface="sans"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:id="@+id/textView_album_count"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
现在,我的问题。我希望两个 TextView 都居中,就像上面的链接一样。但我看到它们在 LinearLayout 的顶部对齐。这是:第一个TextView在LinearLayout的顶部,第二个在它下面,然后就是所有的空闲空间了。我想要做的是看到两个 TextView 都以列表项为中心。
第一次尝试
我使用了 android:layout_gravity="center_vertical",但它不适用于两个 TextView。如果我删除其中一个 TextView,那么另一个就是我想要的位置,但当我添加第二个时不会。
第二次尝试
我已尝试在布局中使用 XML 属性 android:WeightSum="2",在 TextViews 中使用 android:layout_weight="1",但均未成功.
我想知道如何才能获得我在此处链接的列表项。 提前致谢!
【问题讨论】:
-
如果您提供指向某个视图的链接会更容易...material-design.storage.googleapis.com/images/…
-
谢谢,我编辑了。
-
另外,我希望我回答了你的问题;)
标签: android android-layout android-listview material-design