【发布时间】:2014-04-26 19:22:08
【问题描述】:
我想创建如图所示的布局,但我完全不知道如何制作这样的.. 有没有人可以给我一个线索或替代方法?
【问题讨论】:
-
使用框架布局或者你可以使用相对布局。与重心对齐父顶部和文本视图
标签: android layout textview imageview
我想创建如图所示的布局,但我完全不知道如何制作这样的.. 有没有人可以给我一个线索或替代方法?
【问题讨论】:
标签: android layout textview imageview
这样拆分。 线性布局水平中的图像视图和第一个文本视图。 然后这个线性布局水平和第二个文本视图在一个线性布局垂直。
【讨论】:
执行此操作的一种方法是放置TextView,然后将ImageView 覆盖在其上。我认为 RelativeLayout 先定义 TextView 然后再定义 ImageView 可能会成功。您可以切换ImageView 的可见性,但需要确保写入TextView 的任何文本都是在考虑ImageView 的宽度后写入的,以免遮挡任何文本。
【讨论】:
您可以尝试在相对布局中添加两个文本视图,此外还可以添加一个图像视图。 这可能会帮助您入门。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/item_generator"
android:background="#FF000000">
<TextView
android:id="@+id/item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:textColor="#FFF"
android:textSize="18sp" />
<TextView
android:id="@+id/item_title_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_marginTop="16dp"
android:textColor="@color/blue"
android:textSize="16sp" />
<TextView
android:id="@+id/item_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/item_title"
android:layout_below="@+id/item_title"
android:textColor="#888"
android:textSize="14sp" />
<ImageView
android:id="@+id/item_right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_marginRight="40dp"
android:padding="0dp"
android:contentDescription="@string/hello_world" />
</RelativeLayout>
【讨论】: