【发布时间】:2015-04-18 12:14:35
【问题描述】:
我有一个商店布局,其中包含三个不同大小的图像。在它们的右侧,有代表价格的文本。如何将图像和文本对齐?并将屏幕中间放在图像和文本之间。这是我的布局:
<?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="match_parent" android:background="@drawable/podklad">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lives"
android:focusable="false" android:background="@drawable/heart_image"
android:layout_below="@+id/money" android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/price1"
android:textSize="30sp" android:textColor="#ff000000"
android:layout_alignTop="@+id/lives" android:layout_toRightOf="@+id/lives"
android:layout_toEndOf="@+id/lives"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/money" android:layout_alignParentTop="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" android:textSize="40dp" android:textColor="#ff000000"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/monstertoprightcolored"
android:id="@+id/hardmode"
android:layout_centerVertical="true" android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/price2"
android:textSize="30dp"
android:textColor="#ff000000"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/hardmode"
android:layout_toEndOf="@+id/hardmode"
android:layout_above="@+id/price3"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/monsterbottomleftcolored"
android:id="@+id/reversedmode"
android:layout_alignParentBottom="true" android:layout_alignLeft="@+id/hardmode"
android:layout_alignStart="@+id/hardmode"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/price3"
android:textSize="30dp"
android:textColor="#ff000000"
android:layout_marginTop="26dp"
android:layout_below="@+id/hardmode"
android:layout_toRightOf="@+id/price2"
android:layout_toEndOf="@+id/price2"/>
【问题讨论】:
标签: android xml android-layout alignment android-relativelayout