【发布时间】:2013-09-05 16:53:55
【问题描述】:
我有以下 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:padding="2.0dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:textSize="14.0sp"
android:textStyle="bold"
android:textColor="#ff449def"
android:layout_gravity="top|left|center"
android:id="@id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_gravity="left"
android:id="@id/eventvenue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name" />
<TextView
android:layout_gravity="bottom|left|center"
android:id="@id/datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/eventvenue" />
<TextView
android:layout_gravity="left"
android:id="@+id/datetime2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/datetime" />
<ImageView
android:layout_gravity="right"
android:id="@id/customlistrowlogo"
android:padding="5.0dip"
android:layout_width="80.0dip"
android:layout_height="80.0dip"
android:scaleType="fitXY"
android:cropToPadding="true"
android:layout_alignTop="@id/name"
android:layout_alignBottom="@id/datetime2"
android:layout_alignParentRight="true"
android:contentDescription="logo" />
</RelativeLayout>
当应用程序处于垂直模式时,如果其中一个文本视图中的文本太长,则它将换行到下一行并且不会覆盖图像。
但是,当我处于水平模式时,文本不会换行到下一行,而是被图像覆盖。
垂直 ::
----------------------------
| image |
|text text text tex image |
|t wraps around tex image |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
----------------------------
水平::
---------------------------------------------------------------
| |
| text image |
| text text text text text text text text text teimage |
| |
| |
| |
| |
| |
| |
| |
| |
---------------------------------------------------------------
与在垂直模式下文本下降到下一行的垂直模式不同,文本隐藏在图片后面并且不会转到下一行
【问题讨论】:
-
您的示例 xml 并没有真正显示任何内容,因为您的所有控件都有
wrap_content这导致几乎不可见。请查看您的示例代码。 -
@rekire 你是什么意思?不关注
-
我无法理解您的问题,因为您所有控件的宽度都为零。
-
@rekire 见上图
标签: android xml textview android-imageview android-relativelayout