0

在我的应用程序中,我有一个以这种方式显示菜单的视图......但我想为所有类型的屏幕调整这 4 个按钮,也就是说,我希望这些按钮具有动态大小......你有什么建议吗?谢谢在此处输入图像描述

这是我当前的代码...

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.game.SplashActivity" >

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/back_menu" 
    android:scaleType="centerCrop"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
     >



        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:src="@drawable/bt_1_player"
            android:layout_weight="1"
             />




        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:src="@drawable/bt_2_player" 
            android:layout_weight="1"/>


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:src="@drawable/challenge_bt" 
            android:layout_weight="1"/>


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:src="@drawable/special_bt" 
            android:layout_weight="1"/>

</LinearLayout>

4

1 回答 1

2

使用下面的代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back_menu"
android:orientation="vertical"
tools:context="com.example.game.SplashActivity" >


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:src="@drawable/bt_1_player"
        android:layout_weight="1"/>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:src="@drawable/bt_2_player"
        android:layout_weight="1"/>


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:src="@drawable/challenge_bt"
        android:layout_weight="1"/>


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:src="@drawable/special_bt"
        android:layout_weight="1"/>

</LinearLayout>
于 2014-11-11T10:50:53.753 回答