Android:简单菜单的布局

Android:简单菜单的布局,android,android-layout,android-button,android-imagebutton,Android,Android Layout,Android Button,Android Imagebutton,在我的应用程序中,我有一个这样的菜单视图。。。但我想让这4个按钮适应所有类型的屏幕,也就是说,我希望这些按钮有一个动态的大小。。。你有什么建议吗? 谢谢 这是我当前的代码 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_layout" android:l

在我的应用程序中,我有一个这样的菜单视图。。。但我想让这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>

使用下面的代码

<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>


到目前为止,您的XML是什么样子的?带有权重属性的线性布局。我用代码编辑我的问题…这不起作用…Pr38y是对的,请对这些按钮使用
LinearLayout
。如果您想调整按钮的高度,请将每个按钮的高度设置为0dp,并将重量设为1。似乎您正在使用多种包装器布局,只需使用一种,然后将
imageview
放在其中。您也不需要为父布局计算权重总和,只需为每个按钮赋予权重1。好吧,看起来它工作正常。。。只有一件事。。。在7英寸(mdpi)和10.1英寸(mdpi)中,这些按钮仍然很小。。。为什么?我编辑了我的新代码…它可以与imageView一起工作,但不能与ImageButton一起工作