设计布局 Android

Design Layout Android

我尝试在不同的设备上使用我的应用程序,第一个设备是 4.0 英寸屏幕,第二个设备是 5.55 英寸,当我应用第一个设备(4.0 英寸)时,我的应用程序 运行 非常好,但在第二个设备(5.55英寸)屏幕被拉伸。 我的问题是我如何设计所有设备?

第一台设备 4.0 英寸

第二个设备 5.55 英寸 下面我画红色箭头

XML:

 <LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="İzmir Üniversitesi Mobile"
        android:textColor="#EADCCA"
        android:textSize="22sp" 
        android:textStyle="bold"/>
</LinearLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/linearLayout1"
    android:layout_alignRight="@+id/linearLayout1"
    android:layout_marginTop="55dp" >

    <View
        android:id="@+id/view1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:alpha="0.50" />

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

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_marginLeft="25dp" >

            //ÖBS
             <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="Öğrenci Bilgi Sistemi" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_obs"
         />

    //DERS PROGRAMI

     <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ders Programı" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

      <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_dersp" />

      //Akademik Takvim
       <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Akademik Takvim" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

       <ImageButton
        android:id="@+id/imageButton4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_takvim" />

       //İletişim
        <TextView
        android:id="@+id/textView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="İletişim" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

        <ImageButton
        android:id="@+id/imageButton8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_iletisim" />

         <TextView
        android:id="@+id/textView12"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Yemekhanede Bugün" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

        <ImageButton
        android:id="@+id/imageButton11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_yemek" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_marginLeft="10dp" >

            <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:text="Haberler ve Duyurular" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

      <ImageButton
        android:id="@+id/imageButton3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_haber" />

      //Kişisel İşlemler

       <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Kişisel İşlemlerim" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

        <ImageButton
        android:id="@+id/imageButton5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_kisisel" />

        //Ögrenci Web Mail

         <TextView
        android:id="@+id/textView8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Öğrenci Web Mail" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

        <ImageButton
        android:id="@+id/imageButton7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_mesaj" />

        //Online Dersler

        <TextView
        android:id="@+id/textView10"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Online Dersler" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

        <ImageButton
        android:id="@+id/imageButton9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_online" />

        //Ayarlar

        <TextView
        android:id="@+id/textView11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ayarlar" 
        android:textSize="9dp"
        android:textStyle="bold"
        android:textColor="#ffffff"/>

        <ImageButton
        android:id="@+id/imageButton10"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_ayar" />

        </LinearLayout>

    </LinearLayout>

</FrameLayout>

以下是多屏幕设计指南:Supporting Multiple Screens

如果您阅读了指南,您会发现对于您描述的场景,4 英寸和 5.55 英寸都属于同一个布局文件夹(大),因此其中没有解决方案。但是,如果您还针对其他屏幕尺寸(例如平板电脑),则需要阅读它。

要回答您的问题,您可以做的一件事是将阴影框高度设置为 "wrap_content",这样它就不会被拉伸,然后将其重力设置到中心。

如果我有您的布局 xml 文件,我可以提供代码片段。

编辑:使用代码更新

1) 我会完全删除这个视图元素:

<View
     android:id="@+id/view1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:background="#000000"
     android:alpha="0.50" />

2) 我会将这两行添加到移除视图之后的线性布局中

android:background="#000000"
android:alpha="0.50"

3) 我会将以下行添加到已删除视图之前的框架布局中

android:layout_centerInParent="true"

4) 我会将 TextView textView1 放置在框架布局上方