2016-04-15 13 views
0

xmlファイルのレイアウトを編集する方法。すべての表示画面は同じです。デザインレイアウトの表示が同じでない

画面サイズ4.7 "、5.0"表示精度。しかし、これ以外の画面。歪みを表示します。画面のタブレットを除く。

私はそれを修正することができます。

screen_main.xml

<FrameLayout 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" 
    tools:context="jp.vertice.test.MainScreenFragment"> 

    <!-- TODO: Update blank fragment layout --> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#51c8fc"> 

     <ImageView 
      android:layout_width="200dp" 
      android:layout_height="195dp" 
      android:id="@+id/imageView2" 
      android:src="@mipmap/ic_launcher" 
      android:background="#fc0c0c" 
      android:layout_marginLeft="18dp" 
      android:layout_marginStart="18dp" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 

     <ImageButton 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:id="@+id/btn1" 
      android:layout_alignParentTop="true" 
      android:layout_alignLeft="@+id/btn3" 
      android:layout_alignStart="@+id/btn3" /> 

     <ImageButton 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:id="@+id/btn2" 
      android:layout_below="@+id/btn1" 
      android:layout_alignLeft="@+id/btn1" 
      android:layout_alignStart="@+id/btn1" /> 

     <ImageButton 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:id="@+id/btn5" 
      android:layout_below="@+id/btn2" 
      android:layout_alignLeft="@+id/imageView2" 
      android:layout_alignStart="@+id/imageView2" 
      android:layout_marginTop="5dp" /> 

     <ImageButton 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:id="@+id/btn4" 
      android:layout_alignTop="@+id/btn5" 
      android:layout_toRightOf="@+id/btn5" 
      android:layout_toEndOf="@+id/btn5" 
      android:layout_marginLeft="9dp" 
      android:layout_marginStart="9dp" /> 

     <ImageButton 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:id="@+id/btn3" 
      android:layout_alignTop="@+id/btn4" 
      android:layout_toRightOf="@+id/btn4" 
      android:layout_toEndOf="@+id/btn4" 
      android:layout_marginLeft="10dp" 
      android:layout_marginStart="10dp" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="205dp" 
     android:background="#F4F4F4" 
     android:layout_gravity="bottom"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:text="YYYY.MM.DD" 
      android:id="@+id/txt1" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_marginLeft="22dp" 
      android:layout_marginStart="22dp" 
      android:layout_marginBottom="173dp" /> 

     <TextView 
      android:layout_width="230dp" 
      android:layout_height="50dp" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 
      android:id="@+id/text2" 
      android:layout_alignTop="@+id/txt1" 
      android:layout_alignLeft="@+id/txt1" 
      android:layout_alignStart="@+id/txt1" 
      android:layout_marginTop="25dp" /> 

     <Button 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="BUTTON" 
      android:id="@+id/btn6" 
      android:layout_marginLeft="11dp" 
      android:layout_marginStart="11dp" 
      android:layout_alignTop="@+id/text2" 
      android:layout_toRightOf="@+id/text2" 
      android:layout_toEndOf="@+id/text2" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="20dp" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:text="FOOTER" 
      android:id="@+id/textView2" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:textSize="10sp" 
      android:textStyle="bold" 
      android:textAlignment="center" 
      android:gravity="center_vertical" 
      android:background="#FFFFFF" /> 

    </RelativeLayout> 
</FrameLayout> 

Display is not the same

+0

あなたは見たいと思うものは何ですか?つまり、正しいものは何ですか?あなたは4.7 "の例はあなたがすべてのデバイスのために欲しいものなのですか?あなたはタブレットを"特に "意味しますか? – miva2

答えて

0

あなたはGridLayoutのを使用して試すことができます。このようにして、画像列は画面全体を埋めるでしょう。

0

あなたはDPと協力し、あなたがここにweightSumweightで作業することができ、すべてのデバイスで同じ表示をしたい場合は、別の に同じ結果を期待することはできませんが、少し例です

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


     <LinearLayout 
      android:id="@+id/layout1" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 

     <LinearLayout 
      android:id="@+id/layout2" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 
</LinearLayout> 
0

しないでくださいFrame Layoutは、単一のビューを表示するために使用されたため、ここでフレームレイアウトを使用します。

0

layout_widthlayout_heightの固定dp値を使用しています。 dpは、の濃度独立画素を意味します。サイズ独立ピクセルではありません。 dpは、同じサイズでピクセル密度が異なるデバイスでレイアウトが同じに見えるようにします。大きなデバイスでも同じように見えません。 大きいデバイスに拡大縮小する場合は、match_parentwrap_contentを使用する必要があります。 相対レイアウトの力を使って、アイテムを画面の右側に配置します。

異なるサイズのデバイス用に別々のレイアウトファイルを作成することもできます。サイズに合わせてカスタマイズすることができます。 これは、たとえばlayout-sw600dp/(または任意の数値)という名前の新しいレイアウトフォルダを作成することによって行います。このフォルダは、少なくとも指定した幅(この例では600dp)を持つデバイスでのみ使用されます。 レイアウトファイルのフォルダ内の名前が、通常のフォルダと同じであることを確認してください。

この情報は、 herehereという便利な情報があります。

関連する問題