【发布时间】:2011-11-19 22:36:41
【问题描述】:
我正在尝试制作具有 2 列的行布局,就像这张图片中的 http://oi56.tinypic.com/1z2g9k9.jpg
总结
目标是有 2 列。右列的行跨度为 2,因此里面的图标中间垂直对齐左列的 2 行文本。
试试
到目前为止,我所拥有的是一个线性布局,其中包含一个相对布局(对齐两个文本行)和一个用于图标的 ImageView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/relativeLayoutLeft"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="5dip">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_width="wrap_content"
android:id="@+id/BigText"
android:layout_marginLeft="2dip">
</TextView>
<TextView
android:layout_height="wrap_content"
android:text="TextView"
android:layout_width="wrap_content"
android:id="@+id/SmallText"
android:layout_below="@+id/BigText"
android:layout_marginLeft="2dip">
</TextView>
</RelativeLayout>
<ImageView
android:layout_width="50dip"
android:layout_height="50dip"
android:id="@+id/Icon"
android:src="@drawable/icon"
android:layout_gravity="right"
android:scaleType="center">
</ImageView>
</LinearLayout>
问题
问题是RelativeLayout 有100% 的宽度并且图像在屏幕之外。 如果从fill_parent改为wrap_content,则图像不对齐到屏幕的右边缘(因为左列宽度并不总是90%左右)。
【问题讨论】:
标签: android layout vertical-alignment html-table