如何让相对布局适应平板电脑的 [英] how to make relative layout accommodate tablets screen

查看:157
本文介绍了如何让相对布局适应平板电脑的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何布局一样正常屏幕和平板电脑屏幕?
我可以改变线性布局相同的空间和peding?请帮助我是新:)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

家用code是

 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@绘制/ backr
    机器人:paddingBottom会=@扪/ activity_vertical_margin
    机器人:paddingLeft =@扪/ activity_horizo​​ntal_margin
    机器人:paddingRight =@扪/ activity_horizo​​ntal_margin
    机器人:paddingTop =@扪/ activity_vertical_margin
    工具:上下文=FreeDENTAL。>   <按钮
       机器人:ID =@ + ID / buttonlec
       机器人:layout_width =FILL_PARENT
       机器人:layout_height =100dp
       机器人:layout_alignBottom =@ + ID / buttonbook
       机器人:layout_alignLeft =@ + ID / buttonbook
       机器人:layout_marginBottom =47dp
       机器人:背景=@绘制/ cooltext1218143078/><按钮
    机器人:ID =@ + ID / buttonbook
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =50dp
    机器人:layout_alignParentTop =真
    机器人:layout_centerHorizo​​ntal =真
    机器人:layout_marginTop =158dp
    机器人:背景=@绘制/ cooltext1218138491/><按钮
    机器人:ID =@ + ID /按钮1
    风格=机器人:ATTR / buttonStyleSmall
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =50dp
    机器人:layout_alignLeft =@ + ID / buttonbook
    机器人:layout_alignRight =@ + ID / buttonbook
    机器人:layout_below =@ + ID / buttonlec
    机器人:layout_marginTop =18dp
    机器人:背景=@绘制/ cooltext1218134039/><按钮
    机器人:ID =@ + ID /按钮2
    风格=机器人:ATTR / buttonStyleSmall
    机器人:layout_width =160dp
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignLeft =@ + ID /按钮1
    机器人:layout_below =@ + ID /按钮1
    机器人:layout_marginTop =32dp
    机器人:背景=@绘制/ cooltext1218152696/><按钮
    机器人:ID =@ + ID /将Button4
    风格=机器人:ATTR / buttonStyleSmall
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignLeft =@ + ID /按钮2
    机器人:layout_alignRight =@ + ID /按钮2
    机器人:layout_below =@ + ID /按钮2
    机器人:背景=@绘制/提示
    /><按钮
    机器人:ID =@ + ID / button5
    风格=机器人:ATTR / buttonStyleSmall
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignBaseline =@ + ID /按钮2
    机器人:layout_alignBottom =@ + ID /按钮2
    机器人:layout_alignLeft =@ + ID /按钮3
    机器人:layout_alignRight =@ + ID /按钮1
    机器人:背景=@绘制/新闻/><按钮
    机器人:ID =@ + ID /按钮3
    风格=机器人:ATTR / buttonStyleSmall
    机器人:layout_width =125dp
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignBottom =@ + ID /将Button4
    机器人:layout_alignRight =@ + ID /按钮1
    机器人:layout_below =@ + ID /按钮2
    机器人:背景=@绘制/ cooltext1218061123/>< / RelativeLayout的>


解决方案

试着用工作的android:layout_weight ,而不是固定的DP。

正如这里可以看出:
在RelativeLayout的 百分比宽度

how to make the layout same as for normal screen and tablet screen? can I change to linear layout with the same spaces and peding ? please help I'm new :) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

the home code is

<RelativeLayout 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:background="@drawable/backr"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".FreeDENTAL" >

   <Button
       android:id="@+id/buttonlec"
       android:layout_width="fill_parent"
       android:layout_height="100dp"
       android:layout_alignBottom="@+id/buttonbook"
       android:layout_alignLeft="@+id/buttonbook"
       android:layout_marginBottom="47dp"
       android:background="@drawable/cooltext1218143078" />

<Button
    android:id="@+id/buttonbook"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="158dp"
    android:background="@drawable/cooltext1218138491" />

<Button
    android:id="@+id/button1"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/buttonbook"
    android:layout_alignRight="@+id/buttonbook"
    android:layout_below="@+id/buttonlec"
    android:layout_marginTop="18dp"
    android:background="@drawable/cooltext1218134039" />

<Button
    android:id="@+id/button2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="160dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button1"
    android:layout_below="@+id/button1"
    android:layout_marginTop="32dp"
    android:background="@drawable/cooltext1218152696" />

<Button
    android:id="@+id/button4"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button2"
    android:layout_alignRight="@+id/button2"
    android:layout_below="@+id/button2"
    android:background="@drawable/tips"
    />

<Button
    android:id="@+id/button5"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button2"
    android:layout_alignBottom="@+id/button2"
    android:layout_alignLeft="@+id/button3"
    android:layout_alignRight="@+id/button1"
    android:background="@drawable/news" />

<Button
    android:id="@+id/button3"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="125dp"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/button4"
    android:layout_alignRight="@+id/button1"
    android:layout_below="@+id/button2"
    android:background="@drawable/cooltext1218061123" />

</RelativeLayout>

解决方案

Try working with android:layout_weight instead of fixed dp.

As can be seen here: Percentage width in a RelativeLayout

这篇关于如何让相对布局适应平板电脑的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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