cyclingIsBetter
cyclingIsBetter

Reputation: 17591

Android: layout for a simply menu

In my app I have a view with a menu in this way... but I want adapt these 4 buttons for all type of screen, that is I want that these buttons have a dynamic size... do you have any suggestions? thanksenter image description here

this is my current code...

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

Upvotes: 0

Views: 77

Answers (1)

Thirumoorthy
Thirumoorthy

Reputation: 589

use below code.

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

Upvotes: 2

Related Questions