Нет необходимости использовать вложенный макет для этого
Вы можете достичь этого, используя только один LinearLayout
Вы можете установить android:drawableEnd="@drawable/ic_fav"
в вашем EditText
, чтобы заменить кнопку изображения
КОД ОБРАЗЦА
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/coordinatorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:drawableEnd="@drawable/ic_fav"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />
</LinearLayout>
ВЫХОД
![enter image description here](https://i.stack.imgur.com/0k8bm.png)
Другой способ
, если вы не хотите использовать android:drawableEnd
, чем здесь второе решение
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<RelativeLayout
android:layout_width="match_parent"
android:background="@drawable/test"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:ems="10"
android:background="@android:color/transparent"
android:inputType="textPersonName"
android:text="Name" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="37dp"
android:layout_alignParentEnd="true"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="centerInside"
app:srcCompat="@drawable/ic_fav" />
</RelativeLayout>
</LinearLayout>
Drawable / Test
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-10dp"
android:left="-10dp"
android:right="-10dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke android:width="2dp"
android:color="#3498db"/>
</shape>
</item>
</layer-list>
ВЫХОД
![enter image description here](https://i.stack.imgur.com/kfwJG.png)