我是Android的新手,我有一个线性布局列表项,并希望TextView itemName在行的其余空白处填充,而其他两个视图(itemIcon和itemTimestamp)只需占用它们需要的空间,因此使用wrap_content。我尝试过在ItemName android:layout_width上使用fill_parent和match_parent,但最终隐藏了itemTimestamp视图。我尝试了RelativeLayout,但没有成功,如果可能的话,还是喜欢使用Linearlayout。感谢您的帮助。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/itemNotificationBuzz"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffff0000"
>
<LinearLayout
android:id="@+id/notificationHeader"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ffff0000"
>
<ImageView
android:id="@+id/notificationIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:maxHeight="35dp"
android:maxWidth="35dp"
android:background="#FF000000"
android:padding="1dp"
android:src="@drawable/ic_action_place" />
<TextView
android:id="@+id/notificationName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:textSize="18sp"
android:textColor="@android:color/white"
android:background="#A4C739"
android:typeface="sans"
android:textStyle="bold"
android:maxLines="1"
android:text="Fname Lname"
/>
<TextView
android:id="@+id/notificationTimestamp"
android:layout_width = "wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:background="#FF000000"
android:ems="10"
android:maxLines="1"
android:text="2m"
android:textColor="@android:color/white"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>