屏幕布局在大屏幕上看起来不太好

时间:2013-06-07 13:43:09

标签: android

我有3个水平的LinearLayouts,我一直在4.7屏幕上制作xml,它看起来不错,然后我切换到更大的屏幕,它看起来不太好。所以我的xml在屏幕尺寸为4.7时看起来不错,但是在10.01和7上它拧紧了 在4.7屏幕上: enter image description here

on 10,01:enter image description here

<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:background="@drawable/backgroun"
    android:orientation="vertical" 
  >

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal" >

     <Button
         android:id="@+id/button1"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_weight="1"
         android:text="Load" />

     <Button
         android:id="@+id/button2"
         android:layout_width="wrap_content"
        android:layout_height="match_parent"
         android:text="Play"
         android:layout_weight="1" />

     <Button
         android:id="@+id/button3"
         android:layout_width="wrap_content"
        android:layout_height="match_parent"
         android:text="Mute" 
         android:layout_weight="1"/>

     <Button
         android:id="@+id/button4"
         android:layout_width="wrap_content"
        android:layout_height="match_parent"
         android:text="Volume up"
         android:layout_weight="1" />

     <Button
         android:id="@+id/button5"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:text="Volume up"
         android:layout_weight="1" />

     <Button
         android:id="@+id/button6"
         android:layout_width="wrap_content"
        android:layout_height="match_parent"
         android:text="Mute" 
         android:layout_weight="1"/>

     <Button
         android:id="@+id/button7"
         android:layout_width="wrap_content"
        android:layout_height="match_parent"
         android:text="Play"
         android:layout_weight="1"/>

     <Button
         android:id="@+id/button8"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:text="Load"
         android:layout_weight="1" />

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:orientation="horizontal" >

        <SeekBar
            android:id="@+id/seekBar1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:layout_weight="7"/>

        <Button
            android:id="@+id/button9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <SeekBar
            android:id="@+id/seekBar2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
             android:layout_weight="7"/>

    </LinearLayout>
     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >

         <SeekBar
             android:id="@+id/seekBar3"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1" />

         <SeekBar
             android:id="@+id/seekBar4"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1" />

    </LinearLayout>

    </LinearLayout>

2 个答案:

答案 0 :(得分:1)

首先,当您使用android:layout_weight时,您应该设置android:layout_width="0dp"
除此之外,我建议为xlarge屏幕设置单独的布局。
这样做的方法是创建一个单独的文件夹,其中包含与原始布局同名的布局(例如main.xml)。 10&#34;的文件夹名称屏幕应该类似于layout-xlarge
有关详细信息,请查看here

答案 1 :(得分:1)

适用于不同尺寸的屏幕。您还可以为更大的屏幕制作另一种布局。

res / layout-small
res / layout-large
RES /布局XLARGE

创建一个名为“layout-xlarge”的新文件夹,然后在那里复制xml布局,您可以调整大小。

Android会自动为当前设备选择合适的布局。请记住,每个文件夹中的布局名称应该相同。