android - 相对布局避免文本覆盖图像

标签 android android-layout

我正在尝试设置一个布局,该布局将用于 ListActivity 的每一行。每行左侧包含一个灯泡图标,中间包含一个文本,然后右侧包含一个钢笔图标。

我找不到解决方案来避免中心的文本部分过大的话超过 2 个图像。

这是我在屏幕上看到的内容:

Actual Display

当文本太长时,它会显示在灯泡图标钢笔图标

我需要如何修改布局来避免这种情况?

XML:

<RelativeLayout
    android:id="@+id/linearLayoutEquipementInfo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20sp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/equipementImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_margin="10sp"
        android:contentDescription="@string/status" />

    <TextView
        android:id="@+id/equipementName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_margin="10sp"
        android:gravity="center"
        android:text="title"
        android:textSize="22sp" />

    <ImageView
        android:id="@+id/equipementEdit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_margin="1sp"
        android:background="@null"
        android:contentDescription="@string/editEquipmentName"
        android:src="@android:drawable/ic_menu_edit" />
</RelativeLayout>

最佳答案

您可以为 TextView 添加 2 个参数:

android:layout_toRightOf="@id/equipementImage"
android:layout_toLeftOf="@id/equipementEdit"

关于android - 相对布局避免文本覆盖图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11449017/

相关文章:

android - 创建带有选项列表的弹出窗口,例如 Youtube App

android - 在 ScrollView 中使用 RelativeLayout 不会产生滚动

android - 从 URL 加载 GIF

android - 未调用自定义适配器 getview

android - 当 EditText 失去焦点时关闭键盘

android - 将 View 粘贴到 ScrollView 的底部

android - 如何删除彩色 EditText 焦点边框

android - 适用于 Android 的良好 UI 生成器

android - android中的数据漫游

java - 是 M :N a bad style in OOP? 有没有更好的办法来管理 m :n relationships?