不同的布局为多屏 [英] different layouts for multiple screens

查看:112
本文介绍了不同的布局为多屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了不同的文件夹多个屏幕。

RES /布局(正常屏幕)
RES /布局大(大屏幕)
RES /布局XLARGE(用于xhdpi屏幕)

当我在盛大的2手机,这是xhdpi测试,它从RES /布局文件夹中所采用的值...

这是处理多发的屏幕布局以正确的方式......,是有蚂蚁的变化我有Android.manifest文件办?? plz帮助在advance..I me..thanks有两个改变大小滚动条不同的布局...

RES /布局/ main.xml中

 <?XML版本=1.0编码=UTF-8&GT?;<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@绘制/ back1>
    <滚动型
    机器人:layout_width =match_parent
    机器人:layout_height =200dp
    机器人:滚动条=水平><的LinearLayout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>    <的TextView
        机器人:ID =@ + ID / textView2
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =33dp
        机器人:layout_marginTop =2DP
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView4
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =33dp
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView3
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =33dp
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView5
        机器人:layout_width =264dp
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp
        机器人:layout_marginTop =10dp
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>
        < TableLayout
            机器人:ID =@ + ID / maintable
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_marginBottom =5DP
            机器人:layout_marginLeft =20dp>
        < / TableLayout>
        < TableLayout
            机器人:ID =@ + ID / maintable1
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_marginBottom =5DP
            机器人:layout_marginLeft =20dp
            机器人:layout_marginTop =10dp>
        < / TableLayout>    <的TextView
        机器人:ID =@ + ID / textView6
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@机器人:ID /列表
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    < ListView控件
        机器人:ID =@机器人:ID /列表
        风格=机器人:listViewStyle
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =70dp
        机器人:layout_below =@ + ID / textView6
        机器人:layout_marginLeft =33dp
        机器人:drawSelectorOnTop =真
        机器人:文字颜色=#FFFFFF>    < /&的ListView GT;
     < / LinearLayout中>< /滚动型>
<的LinearLayout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:layout_marginBottom =0dp    机器人:方向=横向
      >
    <的TextView
        机器人:ID =@ + ID / textView8
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =7DP
        机器人:layout_gravity =底
        机器人:文字=
        机器人:layout_marginBottom =5DP
        机器人:文字颜色=#FFFFFF
        机器人:textColorLink =#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView7
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =12dp
        机器人:layout_marginTop =1DP
        机器人:layout_marginBottom =5DP
        机器人:文字=
        机器人:layout_gravity =底
        机器人:文字颜色=#FFFFFF
        机器人:textColorLink =#FFFFFF/>
    < / LinearLayout中>
    < / RelativeLayout的>

RES /布局XLARGE

 <?XML版本=1.0编码=UTF-8&GT?;<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@绘制/ back1>
    <滚动型
    机器人:layout_width =match_parent
    机器人:layout_height =400dp
    机器人:滚动条=水平><的LinearLayout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>    <的TextView
        机器人:ID =@ + ID / textView2
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =33dp
        机器人:layout_marginTop =2DP
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView4
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =33dp
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView3
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =33dp
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView5
        机器人:layout_width =264dp
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =10dp
        机器人:layout_marginTop =10dp
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>
        < TableLayout
            机器人:ID =@ + ID / maintable
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_marginBottom =5DP
            机器人:layout_marginLeft =20dp>
        < / TableLayout>
        < TableLayout
            机器人:ID =@ + ID / maintable1
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_marginBottom =5DP
            机器人:layout_marginLeft =20dp
            机器人:layout_marginTop =10dp>
        < / TableLayout>    <的TextView
        机器人:ID =@ + ID / textView6
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@机器人:ID /列表
        机器人:文字=
        机器人:文字颜色=#FFFFFF/>    < ListView控件
        机器人:ID =@机器人:ID /列表
        风格=机器人:listViewStyle
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =70dp
        机器人:layout_below =@ + ID / textView6
        机器人:layout_marginLeft =33dp
        机器人:drawSelectorOnTop =真
        机器人:文字颜色=#FFFFFF>    < /&的ListView GT;
     < / LinearLayout中>< /滚动型>
<的LinearLayout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:layout_marginBottom =0dp    机器人:方向=横向
      >
    <的TextView
        机器人:ID =@ + ID / textView8
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =7DP
        机器人:layout_gravity =底
        机器人:文字=
        机器人:layout_marginBottom =5DP
        机器人:文字颜色=#FFFFFF
        机器人:textColorLink =#FFFFFF/>    <的TextView
        机器人:ID =@ + ID / textView7
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginLeft =12dp
        机器人:layout_marginTop =1DP
        机器人:layout_marginBottom =5DP
        机器人:文字=
        机器人:layout_gravity =底
        机器人:文字颜色=#FFFFFF
        机器人:textColorLink =#FFFFFF/>
    < / LinearLayout中>
    < / RelativeLayout的>


解决方案

您是错误的说法RES /布局XLARGE(用于xhdpi屏幕)。如果你想参加你应该使用华电国际,xhdpi,xxhdpi和xxxhdpi改性剂的密度不同的布局:

  ...
RES /布局华电国际 - >对华电国际的屏幕。
RES /布局xxdpi --->为XHDPI屏幕。
RES /布局xxhdpi --->为XXHDPI屏幕。
...

被用来大XLARGE修饰符(由于Android 3.2它们是德precated,这意味着你应该上述改性剂),以组设备在规模的功能。

http://developer.android.com/guide/practices/screens_support更多信息html的

I have created the different folders for multiple screens..

res/layout (for normal screens) res/layout-large (for large screens) res/layout-xlarge (for xhdpi screens)

when i have tested on grand 2 phone which is xhdpi, It takes the values from res/layout folder...

Is this a correct way to handle mutiple screen layout...and is there ant change I have to do in Android.manifest file??plz help me..thanks in advance..I have change the scrollbar size in two different layout...

res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/back1">
    <ScrollView
    android:layout_width="match_parent"
    android:layout_height="200dp"


    android:scrollbars="horizontal" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >



    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="2dp"
        android:text=""
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:text=""
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:text=""
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="264dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:text=""
        android:textColor="#FFFFFF" />


        <TableLayout
            android:id="@+id/maintable"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="20dp" >
        </TableLayout>




        <TableLayout
            android:id="@+id/maintable1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp" >
        </TableLayout>

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@android:id/list"
        android:text=""
        android:textColor="#FFFFFF" />

    <ListView
        android:id="@android:id/list"
        style=" android:listViewStyle"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:layout_below="@+id/textView6"
        android:layout_marginLeft="33dp"
        android:drawSelectorOnTop="true"
        android:textColor="#FFFFFF" >

    </ListView>
     </LinearLayout>

</ScrollView>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="0dp"

    android:orientation="horizontal"
      >
    <TextView
        android:id="@+id/textView8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="7dp"
        android:layout_gravity="bottom"
        android:text=""
        android:layout_marginBottom="5dp"
        android:textColor="#FFFFFF"
        android:textColorLink="#FFFFFF" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_marginTop="1dp"
        android:layout_marginBottom="5dp"
        android:text=""
        android:layout_gravity="bottom"
        android:textColor="#FFFFFF"
        android:textColorLink="#FFFFFF" />
    </LinearLayout>
    </RelativeLayout>

res/layout-xlarge

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/back1">
    <ScrollView
    android:layout_width="match_parent"
    android:layout_height="400dp"


    android:scrollbars="horizontal" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >



    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="2dp"
        android:text=""
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:text=""
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:text=""
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="264dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:text=""
        android:textColor="#FFFFFF" />


        <TableLayout
            android:id="@+id/maintable"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="20dp" >
        </TableLayout>




        <TableLayout
            android:id="@+id/maintable1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp" >
        </TableLayout>

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@android:id/list"
        android:text=""
        android:textColor="#FFFFFF" />

    <ListView
        android:id="@android:id/list"
        style=" android:listViewStyle"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:layout_below="@+id/textView6"
        android:layout_marginLeft="33dp"
        android:drawSelectorOnTop="true"
        android:textColor="#FFFFFF" >

    </ListView>
     </LinearLayout>

</ScrollView>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="0dp"

    android:orientation="horizontal"
      >
    <TextView
        android:id="@+id/textView8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="7dp"
        android:layout_gravity="bottom"
        android:text=""
        android:layout_marginBottom="5dp"
        android:textColor="#FFFFFF"
        android:textColorLink="#FFFFFF" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_marginTop="1dp"
        android:layout_marginBottom="5dp"
        android:text=""
        android:layout_gravity="bottom"
        android:textColor="#FFFFFF"
        android:textColorLink="#FFFFFF" />
    </LinearLayout>
    </RelativeLayout>

解决方案

You are wrong saying "res/layout-xlarge (for xhdpi screens)". If you want to make different layouts attending to densities you should use hdpi, xhdpi, xxhdpi and xxxhdpi modifiers:

...
res/layout-hdpi ---> for HDPI screens.
res/layout-xxdpi ---> for XHDPI screens.
res/layout-xxhdpi ---> for XXHDPI screens.
...

large and xlarge modifiers were used (since Android 3.2 they are deprecated, meaning you should the modifiers above) to group devices in function of their size.

More information at http://developer.android.com/guide/practices/screens_support.html

这篇关于不同的布局为多屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆