1. Download our Official Android App: Forums for Android!

Apps Android XML Layout Auto Scale

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

  1. smemamian

    smemamian Lurker
    Thread Starter
    Rank:
    None
    Points:
    25
    Posts:
    2
    Joined:
    Jan 6, 2014

    Jan 6, 2014
    2
    0
    25
    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]
     

    Advertisement

  2. Thom

    Thom  
    VIP Member
    Rank:
     #22
    Points:
    1,318
    Posts:
    11,872
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    11,872
    4,903
    1,318
    Male
    Software Developer
    Keene, NH USA
    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
    Rank:
    None
    Points:
    36
    Posts:
    23
    Joined:
    Jan 6, 2014

    Jan 6, 2014
    23
    1
    36
    Male
    Developer
    North Carolina

Share This Page

Loading...