0

ここに投稿したように、 how-can-i-create-layout-for-both-320dp-and-360dp。その質問では、2 つのボタンに関する簡単な例を挙げました。しかし、今では 320 dp のレイアウトを作成しましたが、Motorola Atrix のような 360 dp のレイアウトを作成できませんでした。与えられた解決策は LinearLayout に関連していたため、私のレイアウトは現在相対です。右側の空白スペースを回避または埋めるにはどうすればよいですか?

レイアウト.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/bg_tapfast" >

    <ImageView 
        android:id="@+id/img_logomaior"
        android:layout_width="@dimen/default_width_img_logomaior"
        android:layout_height="@dimen/default_height_img_logomaior"
        android:src="@drawable/img_logomaior"
        android:layout_marginTop="@dimen/margin_top_img_logomaior"
        android:layout_marginLeft="@dimen/margin_left_img_logomaior"
        android:layout_alignParentLeft="true" />    

    <ImageView 
        android:id="@+id/img_mode_tapcolor"
        android:layout_width="@dimen/default_width_mode_tapcolor"
        android:layout_height="@dimen/default_height_mode_tapcolor"
        android:src="@drawable/mode_tapcolor"
        android:layout_marginTop="@dimen/margin_top_mode_tapcolor"
        android:layout_marginLeft="@dimen/margin_left_mode_tapcolor" />     

    <ImageView 
        android:id="@+id/img_mode_tapname"
        android:layout_width="@dimen/default_width_mode_tapname"
        android:layout_height="@dimen/default_height_mode_tapname"
        android:src="@drawable/mode_tapname"
        android:layout_marginTop="@dimen/margin_top_mode_tapname"
        android:layout_marginLeft="@dimen/margin_left_mode_tapname" />       

     <ImageView 
        android:id="@+id/img_mode_tapgroup"
        android:layout_width="@dimen/default_width_mode_tapgroup"
        android:layout_height="@dimen/default_height_mode_tapgroup"
        android:src="@drawable/mode_tapgroup"
        android:layout_marginTop="@dimen/margin_top_mode_tapgroup"
        android:layout_marginLeft="@dimen/margin_left_mode_tapgroup" />     

     <ImageView 
        android:id="@+id/img_tap_2be"
        android:layout_width="@dimen/default_width_tap_2be"
        android:layout_height="@dimen/default_width_tap_2be"
        android:src="@drawable/tap_2be"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="@dimen/margin_left_tap_2be" />

     <ImageView 
        android:id="@+id/img_bt_howtoplay"
        android:layout_width="@dimen/default_width_bt_howtoplay"
        android:layout_height="@dimen/default_height_bt_howtoplay"      
        android:src="@drawable/bt_howtoplay"        
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true" />

</RelativeLayout>

モトローラ アトリックス

モトローラ アトリックス

サムスン ギャラクシー SII

サムスン ギャラクシー SII

4

2 に答える 2

0

これはhttp://developer.android.com/resources/articles/layout-tricks-efficiency.html とこれが役立つかもしれません http://developer.android.com/resources/articles/layout-tricks-merge.html

于 2012-06-20T00:47:07.397 に答える
0

確実にするために、コードを投稿する必要があります。

ただし、次のような属性を RelativeLayout に追加できるはずです。

android:gravity="center_horizontal"

編集: 3 つの ImageViews を独自のレイアウト内に配置し、最上位の親の重力を中央水平に設定すると、すべての ImageViews が互いに相対的に同じ位置に保持されると思いますが、それらもスクートしますいくつかの上にあるので、実行しているデバイスに関係なく中央に配置されます。

このようなもの:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:background="@drawable/bg_tapfast" >


    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
    <ImageView 
        android:id="@+id/img_logomaior"
        android:layout_width="@dimen/default_width_img_logomaior"
        android:layout_height="@dimen/default_height_img_logomaior"
        android:src="@drawable/img_logomaior"
        android:layout_marginTop="@dimen/margin_top_img_logomaior"
        android:layout_marginLeft="@dimen/margin_left_img_logomaior"
        android:layout_alignParentLeft="true" />    

    <ImageView 
        android:id="@+id/img_mode_tapcolor"
        android:layout_width="@dimen/default_width_mode_tapcolor"
        android:layout_height="@dimen/default_height_mode_tapcolor"
        android:src="@drawable/mode_tapcolor"
        android:layout_marginTop="@dimen/margin_top_mode_tapcolor"
        android:layout_marginLeft="@dimen/margin_left_mode_tapcolor" />     

    <ImageView 
        android:id="@+id/img_mode_tapname"
        android:layout_width="@dimen/default_width_mode_tapname"
        android:layout_height="@dimen/default_height_mode_tapname"
        android:src="@drawable/mode_tapname"
        android:layout_marginTop="@dimen/margin_top_mode_tapname"
        android:layout_marginLeft="@dimen/margin_left_mode_tapname" />       

     <ImageView 
        android:id="@+id/img_mode_tapgroup"
        android:layout_width="@dimen/default_width_mode_tapgroup"
        android:layout_height="@dimen/default_height_mode_tapgroup"
        android:src="@drawable/mode_tapgroup"
        android:layout_marginTop="@dimen/margin_top_mode_tapgroup"
        android:layout_marginLeft="@dimen/margin_left_mode_tapgroup" />     

     <ImageView 
        android:id="@+id/img_tap_2be"
        android:layout_width="@dimen/default_width_tap_2be"
        android:layout_height="@dimen/default_width_tap_2be"
        android:src="@drawable/tap_2be"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="@dimen/margin_left_tap_2be" />

     <ImageView 
        android:id="@+id/img_bt_howtoplay"
        android:layout_width="@dimen/default_width_bt_howtoplay"
        android:layout_height="@dimen/default_height_bt_howtoplay"      
        android:src="@drawable/bt_howtoplay"        
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true" />


     </RelativeLayout>

</RelativeLayout>
于 2012-06-20T00:00:45.440 に答える