Привет всем, я делаю игру для Android, и мне нужна помощь в размещении некоторых видов на экране так, чтобы они были пропорциональны экрану.Рассмотрим следующий код XML для моего макета:
<?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="fill_parent"
android:orientation="vertical"
android:background="@drawable/background">
<ImageView android:src="@drawable/logo" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/logo" ></ImageView>
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="2">
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/buttons">
<LinearLayout android:id="@+id/main_layout" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal">
<ImageView
android:paddingRight="15dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/menu_start_button"
android:id="@+id/start_button">
</ImageView>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/menu_tutorial_button"
android:id="@+id/tutorial_button">
</ImageView>
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="bottom" android:layout_alignParentRight="true" android:id="@+id/option_buttons">
<ImageView android:id="@+id/option_sound" android:src="@drawable/option_sound" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingRight="5dp" android:paddingBottom="5dp"/>
<ImageView android:id="@+id/option_vibrate" android:layout_width="wrap_content" android:src="@drawable/option_vibrate" android:layout_height="wrap_content" android:paddingBottom="5dp" android:paddingRight="5dp"></ImageView>
<ImageView android:id="@+id/option_show_help" android:layout_width="wrap_content" android:src="@drawable/option_show_help" android:layout_height="wrap_content"android:paddingRight="5dp"></ImageView>
</LinearLayout>
</FrameLayout>
Я хочу, чтобы логотип (с идентификатором logo
) занимал верхние 30% экрана.FrameLayout занимает нижние 30% экрана и имеет две кнопки в середине (обернутые в ScrollView с идентификатором buttons
) и три кнопки выбора, которые должны быть справа от FrameLayout (но по какой-то причинена левой стороне) выровнены по вертикали.android:layout_weight
не помогает мне решить мою проблему, так как я хотел бы, чтобы эти просмотры были пропорциональны экрану.Так есть ли элегантное решение моей проблемы, или мне нужно было бы сделать немного хитрого волшебства?