Как центрировать изображение по вертикали в этом RelativeLayout
У меня есть ниже макет, который в основном показывает "сообщения" как более яркие, чем встроенные "Сообщения".
Мне просто нужно показать изображение стрелки справа, показано изображение, но мне нужно, чтобы он был центрирован по вертикали.
Я попытался добавить "android:gravity="center_vertical"
к изображению, но это не повлияло.
любая подсказка?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/wrapper"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00DBE2ED" >
<RelativeLayout
android:id="@+id/wrapper2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00DBE2ED" >
<EditText
android:id="@+id/comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:editable="false"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginLeft="5dip"
android:background="@drawable/bubble_yellow"
android:paddingLeft="10dip"
android:text="Hello bubbles!"
android:textColor="@android:color/primary_text_light" />
<TextView
android:id="@+id/sender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dip"
android:paddingLeft="5dip"
android:paddingRight="2dip"
android:text="Hello bubbles!"
android:textColor="#b9dcdcdc"
android:textSize="11sp"
android:layout_below="@+id/comment" />
<ImageView
android:id="@+id/aquaplayicon"
android:src="@drawable/aquaplayicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="onClickGirl"
android:layout_alignParentRight="true"
android:paddingRight="3dip"
android:gravity="center_vertical" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Ответы
Ответ 1
Атрибут тяжести не для макета, так как это атрибут LinearLayout
, а ваш ImageView
находится внутри вашего RelativeLayout
. Вместо этого удалите строку
android:gravity="center_vertical"
и добавьте строку
android:layout_centerVertical="true"
Ответ 2
Атрибут, который вы ищете, android:layout_centerVertical="true"