1. Are you ready for the Galaxy S20? Here is everything we know so far!

Android XML Layout Auto Scale

Discussion in 'Android Development' started by smemamian, Jan 6, 2014.

  1. smemamian

    smemamian Lurker
    Thread Starter

    on different screen size, my layout becomes smaller than expected. So is there any way to make the layout keep the same ratio on all screen? in other word how can I do scaling my layout ?

    I think that my layout using drawable-mdpi Instead of drawable xhdpi.

    Mylayout:
    [HIGH]
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:eek:rientation="vertical"
    android:layout_gravity="center_vertical"
    tools:context=".MainActivity" >

    <!-- One Two Button -->
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:eek:rientation="horizontal"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="20dp"
    android:layout_weight="1"
    >


    <RelativeLayout
    android:id="@+id/one_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:layout_marginRight="10dp"
    android:padding="20dp" >

    <ImageView
    android:id="@+id/one_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
    </RelativeLayout>


    <RelativeLayout
    android:id="@+id/two_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:padding="20dp" >

    <ImageView
    android:id="@+id/two_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
    </RelativeLayout>
    </LinearLayout>


    <!-- Three Four Button -->
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:eek:rientation="horizontal"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="20dp"
    android:layout_weight="1"
    >


    <RelativeLayout
    android:id="@+id/three_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:layout_marginRight="10dp"
    android:padding="20dp" >

    <ImageView
    android:id="@+id/three_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
    </RelativeLayout>

    <RelativeLayout
    android:id="@+id/four_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:padding="20dp" >

    <ImageView
    android:id="@+id/four_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
    </RelativeLayout>
    </LinearLayout>

    <!-- Five Six Button -->
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:eek:rientation="horizontal"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="20dp"
    android:layout_weight="1"
    >


    <RelativeLayout
    android:id="@+id/five_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:layout_marginRight="10dp"
    android:padding="20dp" >

    <ImageView
    android:id="@+id/five_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
    </RelativeLayout>

    <RelativeLayout
    android:id="@+id/six_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:padding="20dp" >

    <ImageView
    android:id="@+id/six_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
    </RelativeLayout>
    </LinearLayout>
    </LinearLayout>[/HIGH]manifest:
    [HIGH]
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ex30"
    android:versionCode="1"
    android:versionName="1.0" >
    <supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

    <uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="11" />

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
    android:name="com.example.ex30.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    </application>

    </manifest>[/HIGH][​IMG]
    [​IMG]
    [​IMG]
     


  2. Welcome to Android Forums. This thread was moved from Android Lounge to the forum where application development questions are discussed.

    ... Thom
     
  3. venom2124

    venom2124 Newbie

Loading...

Share This Page

Loading...