Android 屏幕右侧的ImageButton

Android 屏幕右侧的ImageButton,android,android-layout,Android,Android Layout,我想在屏幕右侧添加imagebuttom,如下所示: Imageview textview ImageButtom 问题是我什么都试了,但都没用 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" andr

我想在屏幕右侧添加imagebuttom,如下所示:

Imageview textview                                              ImageButtom
问题是我什么都试了,但都没用

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f5f5f5">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="0dp"
        android:id="@+id/card_view"
        android:layout_marginBottom="1dp"
        android:layout_marginEnd="0dp"
        android:layout_marginLeft="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginStart="0dp"
        android:layout_marginTop="0dp">

        <LinearLayout
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >


                <ImageView
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:id="@+id/ProfilePic"
                    android:paddingBottom="20dp"
                    android:paddingLeft="3dp"
                    android:adjustViewBounds="true" />

                <TextView
                    android:id="@+id/textViewName"
                    android:textStyle="bold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingBottom="20dp"
                    android:paddingLeft="1dp"
                    />

                <ImageButton
                    android:id="@+id/imageButton"
                    android:layout_width="20dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/ic_launcher"
                    android:contentDescription="..."
                    android:background="@null"
                    android:layout_gravity="right|center" />

            </LinearLayout>

            <ImageView
...


您可以在ImageButton之前添加一个具有
weight=1
width=0dp
的空格:

<LinearLayout ...>

<TextView .../>    

<Space
    android:layout_width="0dp"
    android:layout_height="1dp"
    android:layout_weight="1"/>

<ImageButton .../>   

</LinearLayout>

您可以在图像按钮前添加一个空间,该空间具有
权重=1
宽度=0dp

<LinearLayout ...>

<TextView .../>    

<Space
    android:layout_width="0dp"
    android:layout_height="1dp"
    android:layout_weight="1"/>

<ImageButton .../>   

</LinearLayout>

尝试将
TextView
layout\u weight
属性设置为1,以便占据
ImageView
ImageButton
之间的整个空间:

     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >


         <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:id="@+id/ProfilePic"
            android:paddingBottom="20dp"
            android:paddingLeft="3dp"
            android:adjustViewBounds="true" />

            <TextView
                android:id="@+id/textViewName"
                android:textStyle="bold"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:paddingBottom="20dp"
                android:paddingLeft="1dp"
                />

            <ImageButton
                android:id="@+id/imageButton"
                android:layout_width="20dp"
                android:layout_height="30dp"
                android:src="@mipmap/ic_launcher"
                android:contentDescription="..."
                android:background="@null"
                android:layout_gravity="right|center" />

      </LinearLayout>

但是


我强烈建议您查看。

尝试将
TextView
layout\u weight
属性设置为1,这样它就占据了
ImageView
ImageButton
之间的整个空间:

     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >


         <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:id="@+id/ProfilePic"
            android:paddingBottom="20dp"
            android:paddingLeft="3dp"
            android:adjustViewBounds="true" />

            <TextView
                android:id="@+id/textViewName"
                android:textStyle="bold"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:paddingBottom="20dp"
                android:paddingLeft="1dp"
                />

            <ImageButton
                android:id="@+id/imageButton"
                android:layout_width="20dp"
                android:layout_height="30dp"
                android:src="@mipmap/ic_launcher"
                android:contentDescription="..."
                android:background="@null"
                android:layout_gravity="right|center" />

      </LinearLayout>

但是


我强烈建议您看看。

尝试在相对布局上更改线性布局,并设置android:layout\u alignParentEnd=“true”


]]>

尝试在相对布局上更改线性布局,并设置android:layout\u alignParentEnd=“true”


]]>