[英]How can I achieve this listview row layout in XML?
I can't seem to get the date positioned appropriately in the layout. 我似乎无法在布局中正确定位日期。 I am trying to achieve something like this:
我正在尝试实现以下目标:
I need to have the date appear below the first line of the notifications. 我需要让日期显示在通知的第一行下方。 I'm just not sure how to incorporate a vertical linear layout here properly.
我只是不确定如何在此处正确合并垂直线性布局。
Here's the XML code I have so far: 这是我到目前为止的XML代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/user_avatar_notification"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/post_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="username"
android:textSize="16dp" />
<TextView
android:id="@+id/post_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="mentioned you in a"
android:textColor="@color/comment_like_grey" />
<TextView
android:id="@+id/notification_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="not_type"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date of notification"
android:textColor="@color/comment_like_grey"
/>
</LinearLayout>
Try something like this: 尝试这样的事情:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/user_avatar_notification"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/post_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="username"
android:textSize="16dp" />
<TextView
android:id="@+id/post_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="mentioned you in a"
android:textColor="@color/comment_like_grey"/>
<TextView
android:id="@+id/notification_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="not_type" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date of notification"
android:textColor="@color/comment_like_grey"/>
</LinearLayout>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.