[英]How can I make my ListViewItem look like the Twitter app?
I want my row items to look like this: 我希望我的行项目看起来像这样:
I want to have an image on the left, top and bottom text and a date. 我想在左侧,顶部和底部的文字以及日期上添加图片。 I have started to lay it out, but am not sure how to proceed with the rest of the XML:
我已经开始进行布局,但是不确定如何继续其余的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:id="@+id/avatarImageView">
</ImageView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/usernameTextView"
android:text="username"
android:layout_toRightOf="@+id/avatarImageView"
android:layout_alignParentTop="true">
</TextView>
<TextView
android:id="@+id/bodyTextView"
android:layout_below="@+id/usernameTextView"
android:layout_toRightOf="@+id/avatarImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="body">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/usernameTextView"
android:id="@+id/dateTextView"
android:text="date">
</TextView>
</RelativeLayout>
You'll want to check out RelativeLayout, its much easier for layouts like this, it'd be something like. 您将要查看RelativeLayout,它对于像这样的布局要容易得多,就像这样。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView id="@+id/badge"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
.../>
<TextView id="@+id/title"
android:layout_toRightOf="@id/badge"
android:layout_alignParentTop="true"
....
/>
<TextView id="@+id/body"
android:layout_below="@id/title"
android:layout_toRightOf="@id/badge"
....
/>
</RelativeLayout>
Otherwise you need to nest mixed LinearLayouts, eg an outer left to right LinearLayout, then a nested vertical Lineaar Layout for title & body, etc. 否则,您需要嵌套混合的LinearLayouts,例如从左到右的外部LinearLayout,然后是用于标题和正文的嵌套的垂直Lineaar Layout,等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.