У меня два вопроса:
В макете xml есть
ImageButton
, который является ресурсом. При наличии drawable-ldpi в xxhdpi разных размеров для этого imageButton ширина варьируется в зависимости от того, на каком устройстве запущено приложение. Внизу макета xml есть кнопка с 9 патчами, ширина которой должна совпадать с шириной кнопки drawable / imageButton.Как мне унаследовать динамику от 1. до второй кнопки с 9 патчами в другом макете xml?
Я попытался сделать RelativeLayout
с wrap_content
, который красиво обтекает все вокруг. Когда я устанавливаю buttonStart
width на match_parent
, он использует весь экран, а не ширину из UIWrapper. Любая помощь приветствуется. Спасибо!
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_activity_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:focusable="true"
android:screenOrientation="portrait"
tools:context=".MainActivity" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/UIWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/my_gfx" />
<TextView
android:id="@+id/textViewTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal|top"
android:clickable="false"
android:shadowColor="@color/LightYellow"
android:shadowDx="0.0"
android:shadowDy="0.0"
android:shadowRadius="24"
android:text="Some Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/DarkBlue"
android:textSize="48dp" />
</RelativeLayout>
<TextView
android:id="@+id/T0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageWrapper"
android:layout_below="@+id/imageWrapper"
android:layout_marginTop="10dp"
android:text="@string/label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/FloralWhite" />
<RadioGroup
android:id="@+id/T1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/T0"
android:layout_below="@+id/T0" >
<RadioButton
android:id="@+id/radioButton0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:enabled="true"
android:singleLine="true"
android:text="@string/rd_0"
android:textColor="@color/White" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="true"
android:text="@string/rd1"
android:textColor="@color/FloralWhite" />
</RadioGroup>
<Button
android:id="@+id/buttonStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="14dp"
android:background="@drawable/default_button"
android:text="@string/btn_start"
android:textColor="@color/FloralWhite" />
</RelativeLayout>
</RelativeLayout>