Я пытаюсь создать представление, содержащее некоторые элементы в порядке слева направо и кнопку, прикрепленную к правому верхнему углу с фиксированным размером. Мой текущий макет:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2">
<LinearLayout
android:orientation="horizontal"
android:layout_column="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/Image1"
android:layout_height="40dp"
android:layout_width="40dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="16dp"
android:src="@drawable/image_src"
android:visibility="gone" />
<TextView
android:id="@+id/Text1"
android:text="SampleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="24dp"
android:textSize="16sp"
android:gravity="center" />
</LinearLayout>
<ImageButton
android:id="@+id/Button1"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="right"
android:layout_column="1"
android:src="@drawable/imageBtn"
style="?android:attr/borderlessButtonStyle" />
</GridLayout>
Когда текст короткий, кажется, что все в порядке
Но проблема в том, что текст может быть очень длинным, и он перекрывает кнопку.
Как я могу сделать кнопку всегда видимой, а текст переноситься точно в ее левый угол?
RelativeLayout
илиLinearLayout
, вы можете добиться того, чего хотите, используя любой из этих макетов. - person Meet Vora   schedule 13.12.2016