android - 自定义 Listview Row textview Text 将 Imageview 推到右边

标签 android image listview textview row

我正在尝试制作一个简单的 ListView

image_Left + textview_center + image_Right 但是我遇到了一个问题(见图)enter image description here

textview pushing image_Right 解决此问题的任何解决方案

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffff"
android:orientation="horizontal"
android:padding="5dip" >
<LinearLayout android:id="@+id/thumbnail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="3dip"
    android:layout_alignParentLeft="true"
    android:background="#ffff"
    android:layout_marginRight="5dip">

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:src="@drawable/info"/>
</LinearLayout>
<TextView
    android:id="@+id/solutionText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textStyle="normal"
    android:typeface="normal"
    android:textColor="#383838"
    android:textSize="@dimen/activity_horizontal_margin"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/thumbnail"
    android:layout_toEndOf="@+id/thumbnail" />

<ImageView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/more"
    android:padding="4dp"
    android:layout_centerVertical="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:id="@+id/imageView" />

</RelativeLayout>

最佳答案

我对您的代码本身进行了一些更改,请尝试将您的代码替换为使用 layout_weightweightSum 属性概念的代码。阅读this有关重量的信息。祝你好运

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffff"
android:orientation="horizontal"
android:weightSum="10"
android:gravity="center_vertical"
android:padding="5dip" >

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="0dp"
        android:layout_weight="2"
        android:layout_height="50dip"
        android:src="@drawable/info"/>

    <TextView
        android:id="@+id/solutionText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:textStyle="normal"
        android:typeface="normal"
        android:textColor="#383838"
        android:layout_weight="6"
        android:textSize="@dimen/activity_horizontal_margin" />

    <ImageView 
        android:layout_weight="2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:src="@drawable/more"
        android:padding="4dp"
        android:id="@+id/imageView" />

</LinearLayout>

关于android - 自定义 Listview Row textview Text 将 Imageview 推到右边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43020844/

相关文章:

android - 为什么我的 recyclerview 从微调器中选择时有 2 行相同的数据?

android - 找不到检测目标软件包Firebase错误

c# - .net 4.5 框架中用于图像编辑的命名空间

image - 如何使用 tkinter/ttk 在 Python 3 中显示图像?

jquery - 使用 jquery 图像旋转器无法正确堆叠图像

java - 在微调器中选择项目然后单击按钮时从数据库填充 ListView

android - ClassCastException : android. 应用程序

Android:检测 ScrollView 何时完成滚动和弹回?

c# - 如何使用触摸将元素拖出可滚动的 ListView,而无需按住元素 [UWP]

android其他activity点击返回键到listview,listview项无法在选项卡下点击