简体   繁体   中英

Layout not adjusting to all screen size

I have created an android application. It is according screen size 320*480. but when i uses different device with different screen size designs not so proper as required. how can i resolve this issue.please suggest how to create design that fits on all screen size. my current layout is:-

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:orientation="vertical"
android:weightSum="2.0" >

<include
    android:id="@+id/mainScreenHeader"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.4"
    layout="@layout/main_screen_header" />

<include
    android:id="@+id/mainScreenListHeader"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.1"
    layout="@layout/main_screen_list_header" >
</include>

<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1.0"
    android:cacheColorHint="#00000000"
    android:drawSelectorOnTop="false" />

<include
    android:id="@+id/mainScreenFilterClient"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_marginTop="10dp"
    android:layout_weight="0.2"
    layout="@layout/main_screen_filter_client" >
</include>

<include
    android:id="@+id/footer"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.2"


    layout="@layout/footer" >
</include>

This is one of the challenges of developing on Android. There are many different android devices with many different display characteristics. The dev guide gives a good overview of this topic:

http://developer.android.com/guide/practices/screens_support.html

Probably what you will want to do, is to provide different layouts for different screens. The above link discusses that approach.

First of all, this link will help in understanding how to support multiple screed sizes.

It is preferable to add folders to resources folder in Android project to support many resolutions such as:

layout-large

layout-small

layout-xlarge

layout-normal-port-xhdpi-1280x800

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM