Я пытаюсь заставить строку ListView быть похожей на следующее:
| Text-Text-Text <ImageButton> |
С imagebutton, сфотографированным к правому краю. Как я могу сделать это? Вот код текущего макета, который я использую. Что я делаю неправильно?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layercontainer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#699">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YO HOW SI IT GOESSDA" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="right">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/trash" />
</LinearLayout>
</LinearLayout>
Мой код в настоящее время производит это:
Шаг №1: Используйте базу RelativeLayout
.
Шаг №2: Поместите свой ImageButton
как имеющий android: layout_alignParentRight = "true"
Шаг №3: Поместите свой TextView
с android : layout_alignParentLeft = "true"
, android: layout_toLeftOf = "..."
(где ...
- это идентификатор вашего ImageButton
), и, возможно, какое-то другое значение RelativeLayout.LayoutParams
для вертикального выравнивания