设计为5英寸的布局,在android系统平板电脑10寸 [英] Designing the layout for 5 inch to 10inch tablet in android

查看:138
本文介绍了设计为5英寸的布局,在android系统平板电脑10寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建的Nexus 7 THST的布局7寸的平板电脑,但我想开发5英寸到10英寸的平板电脑相同的布局
我的code为porperly工作的Nexus 7,但不能在其他平板电脑所以对此有任何解决方案

下面是XML code

\r
\r

<?XML版本=1.0编码=UTF-8? >\r
<滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android\r
    机器人:layout_width =match_parent\r
    机器人:layout_height =match_parent\r
    机器人:背景=@颜色/背景>\r
\r
    < RelativeLayout的\r
        机器人:layout_width =match_parent\r
        机器人:layout_height =match_parent\r
        机器人:可点击=真正的>\r
\r
        < ImageView的\r
            机器人:ID =@ + ID / ui_logo\r
            机器人:layout_width =100dp\r
            机器人:layout_height =90dp\r
            机器人:layout_alignBottom =@ + ID / tc_mangClass\r
            机器人:layout_centerHorizo​​ntal =真\r
            机器人:layout_marginBottom =32dp\r
            机器人:scaleType =fitXY\r
            机器人:SRC =@绘制/标志/>\r
\r
        <的TextView\r
            机器人:ID =@ + ID / tc_mangClass\r
            机器人:layout_width =WRAP_CONTENT\r
            机器人:layout_height =WRAP_CONTENT\r
            机器人:layout_centerHorizo​​ntal =真\r
            机器人:layout_marginTop =170dp\r
            机器人:fontFamily中=FONT /的Roboto-Light.ttf\r
            机器人:文字=@字符串/ tc_mangClass\r
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium\r
            机器人:文字颜色=@色/白\r
            机器人:TEXTSIZE =@扪/ mangClass/>\r
\r
\r
        <的EditText\r
            机器人:ID =@ + ID / ui_uname\r
            机器人:layout_width =match_parent\r
            机器人:layout_height =match_parent\r
            机器人:layout_below =@ + ID / tc_mangClass\r
            机器人:layout_marginLeft =25dp\r
            机器人:layout_marginRight =25dp\r
            机器人:layout_marginTop =25dp\r
            机器人:drawableLeft =@绘制/用户\r
            机器人:drawablePadding =28dp\r
            机器人:fontFamily中=FONT /的Roboto-Light.ttf\r
            机器人:提示=@字符串/的uname\r
            安卓的inputType =TEXT\r
            机器人:paddingBottom会=10dp\r
            机器人:paddingTop =20dp\r
            机器人:文字颜色=@色/白\r
            机器人:textColorHint =@彩色/ whitedul\r
            机器人:TEXTSIZE =18dp/>\r
\r
        <的EditText\r
            机器人:ID =@ + ID / ui_upass\r
            机器人:layout_width =match_parent\r
            机器人:layout_height =match_parent\r
            机器人:layout_below =@ + ID / ui_uname\r
            机器人:layout_marginLeft =25dp\r
            机器人:layout_marginRight =25dp\r
            机器人:layout_marginTop =8DP\r
            机器人:drawableLeft =@绘制/密码\r
            机器人:drawablePadding =28dp\r
            机器人:fontFamily中=FONT /的Roboto-Light.ttf\r
            机器人:提示=@字符串/ upass\r
            安卓的inputType =textPassword\r
            机器人:paddingBottom会=10dp\r
            机器人:paddingTop =15dp\r
            机器人:文字颜色=@色/白\r
            机器人:textColorHint =@彩色/ whitedul\r
            机器人:TEXTSIZE =18dp/>\r
\r
        <的EditText\r
            机器人:ID =@ + ID / ui_u code\r
            机器人:layout_width =match_parent\r
            机器人:layout_height =match_parent\r
            机器人:layout_below =@ + ID / ui_upass\r
            机器人:layout_marginLeft =25dp\r
            机器人:layout_marginRight =25dp\r
            机器人:layout_marginTop =8DP\r
            机器人:drawableLeft =@绘制/ EDU\r
            机器人:drawablePadding =14dp\r
            机器人:fontFamily中=FONT /的Roboto-Light.ttf\r
            机器人:提示=@字符串/ U code\r
            安卓的inputType =数字\r
            机器人:paddingBottom会=10dp\r
            机器人:paddingTop =15dp\r
            机器人:文字颜色=@色/白\r
            机器人:textColorHint =@彩色/ whitedul\r
            机器人:TEXTSIZE =18dp/>\r
\r
        <复选框\r
            机器人:ID =@ + ID / ui_rember\r
            机器人:layout_width =WRAP_CONTENT\r
            机器人:layout_height =40dp\r
            机器人:layout_below =@ + ID / ui_u code\r
            机器人:layout_marginLeft =25dp\r
            机器人:layout_marginTop =8DP\r
            安卓:检查=真/>\r
\r
        <的TextView\r
            机器人:ID =@ + ID / ui_remText\r
            机器人:layout_width =WRAP_CONTENT\r
            机器人:layout_height =WRAP_CONTENT\r
            机器人:layout_below =@ + ID / ui_u code\r
            机器人:layout_marginLeft =75dp\r
            机器人:layout_marginTop =18dp\r
            机器人:文字=@字符串/ remText\r
            机器人:文字颜色=@色/白\r
            机器人:textIsSelectable =假\r
            机器人:TEXTSIZE =@扪/ remtext/>\r
\r
        <按钮\r
            机器人:ID =@ + ID / ui_login\r
            机器人:layout_width =match_parent\r
            机器人:layout_height =WRAP_CONTENT\r
            机器人:layout_alignStart =@ + ID / ui_rember\r
            机器人:layout_below =@ + ID / ui_rember\r
            机器人:layout_marginRight =25dp\r
            机器人:layout_marginTop =25dp\r
            机器人:背景=@绘制/ button_back\r
            机器人:fontFamily中=FONT /的Roboto-ThinItalic.ttf\r
            机器人:文字=@字符串/登录\r
            机器人:文字颜色=@色/白\r
            机器人:TEXTSIZE =@扪/ TSIZE/>\r
\r
\r
        <的TextView\r
            机器人:ID =@ + ID / ui_fpass\r
            机器人:layout_width =WRAP_CONTENT\r
            机器人:layout_height =WRAP_CONTENT\r
            机器人:layout_below =@ + ID / ui_login\r
            机器人:layout_marginLeft =175dp\r
            机器人:layout_marginTop =25dp\r
            机器人:文字=@字符串/ fpass\r
            机器人:文字颜色=@色/白/>\r
\r
\r
        <查看\r
            机器人:ID =@ + ID /除法\r
            机器人:layout_width =1DP\r
            机器人:layout_height =27dp\r
            机器人:layout_below =@ + ID / ui_login\r
            机器人:layout_centerHorizo​​ntal =真\r
            机器人:layout_marginTop =21dp\r
            机器人:背景=@色/白>\r
\r
        < /视图>\r
\r
        <的TextView\r
            机器人:ID =@ + ID / ui_ codeFinder\r
            机器人:layout_width =WRAP_CONTENT\r
            机器人:layout_height =WRAP_CONTENT\r
            机器人:layout_alignTop =@ + ID / ui_fpass\r
            机器人:layout_marginStart =15dp\r
            机器人:layout_toEndOf =@ + ID /除法\r
            机器人:文字=@字符串/ scfind\r
            机器人:文字颜色=@色/白/>\r
\r
    < / RelativeLayout的>\r
< /滚动型>

\r

\r
\r


解决方案

一个解决方案给予高度和宽度在DP您的看法,和DP应dimens.xml文件中创建,在layout_height和layout_width给来自@dimens参考文件

检查:
<一href=\"http://stackoverflow.com/questions/28939905/android-which-values-folders-i-have-created-for-support-all-resolutions-include/28940014#28940014\">Click这里

I have created the layout for nexus 7 thst is 7 inch tablet but i want to develop the same layout for 5 inch to 10 inch tablet my code is working porperly on nexus 7 but not on other tablet so is there any solution for this

below is the XML code

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true">

        <ImageView
            android:id="@+id/ui_logo"
            android:layout_width="100dp"
            android:layout_height="90dp"
            android:layout_alignBottom="@+id/tc_mangClass"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="32dp"
            android:scaleType="fitXY"
            android:src="@drawable/logo" />

        <TextView
            android:id="@+id/tc_mangClass"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="170dp"
            android:fontFamily="font/Roboto-Light.ttf"
            android:text="@string/tc_mangClass"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/white"
            android:textSize="@dimen/mangClass" />


        <EditText
            android:id="@+id/ui_uname"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/tc_mangClass"
            android:layout_marginLeft="25dp"
            android:layout_marginRight="25dp"
            android:layout_marginTop="25dp"
            android:drawableLeft="@drawable/user"
            android:drawablePadding="28dp"
            android:fontFamily="font/Roboto-Light.ttf"
            android:hint="@string/uname"
            android:inputType="text"
            android:paddingBottom="10dp"
            android:paddingTop="20dp"
            android:textColor="@color/white"
            android:textColorHint="@color/whitedul"
            android:textSize="18dp" />

        <EditText
            android:id="@+id/ui_upass"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/ui_uname"
            android:layout_marginLeft="25dp"
            android:layout_marginRight="25dp"
            android:layout_marginTop="8dp"
            android:drawableLeft="@drawable/password"
            android:drawablePadding="28dp"
            android:fontFamily="font/Roboto-Light.ttf"
            android:hint="@string/upass"
            android:inputType="textPassword"
            android:paddingBottom="10dp"
            android:paddingTop="15dp"
            android:textColor="@color/white"
            android:textColorHint="@color/whitedul"
            android:textSize="18dp" />

        <EditText
            android:id="@+id/ui_ucode"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/ui_upass"
            android:layout_marginLeft="25dp"
            android:layout_marginRight="25dp"
            android:layout_marginTop="8dp"
            android:drawableLeft="@drawable/edu"
            android:drawablePadding="14dp"
            android:fontFamily="font/Roboto-Light.ttf"
            android:hint="@string/ucode"
            android:inputType="number"
            android:paddingBottom="10dp"
            android:paddingTop="15dp"
            android:textColor="@color/white"
            android:textColorHint="@color/whitedul"
            android:textSize="18dp" />

        <CheckBox
            android:id="@+id/ui_rember"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_below="@+id/ui_ucode"
            android:layout_marginLeft="25dp"
            android:layout_marginTop="8dp"
            android:checked="true" />

        <TextView
            android:id="@+id/ui_remText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ui_ucode"
            android:layout_marginLeft="75dp"
            android:layout_marginTop="18dp"
            android:text="@string/remText"
            android:textColor="@color/white"
            android:textIsSelectable="false"
            android:textSize="@dimen/remtext" />

        <Button
            android:id="@+id/ui_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignStart="@+id/ui_rember"
            android:layout_below="@+id/ui_rember"
            android:layout_marginRight="25dp"
            android:layout_marginTop="25dp"
            android:background="@drawable/button_back"
            android:fontFamily="font/Roboto-ThinItalic.ttf"
            android:text="@string/login"
            android:textColor="@color/white"
            android:textSize="@dimen/tsize" />


        <TextView
            android:id="@+id/ui_fpass"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ui_login"
            android:layout_marginLeft="175dp"
            android:layout_marginTop="25dp"
            android:text="@string/fpass"
            android:textColor="@color/white" />


        <View
            android:id="@+id/divider"
            android:layout_width="1dp"
            android:layout_height="27dp"
            android:layout_below="@+id/ui_login"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="21dp"
            android:background="@color/white">

        </View>

        <TextView
            android:id="@+id/ui_codeFinder"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/ui_fpass"
            android:layout_marginStart="15dp"
            android:layout_toEndOf="@+id/divider"
            android:text="@string/scfind"
            android:textColor="@color/white" />

    </RelativeLayout>
</ScrollView>

解决方案

One solution to give height and width to your views in dp, and dp should be created in dimens.xml file, in layout_height and layout_width give reference from @dimens file

Check this: Click Here

这篇关于设计为5英寸的布局,在android系统平板电脑10寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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