2011-01-12 10 views
10

RelativeLayoutを使用して、画面の右下と左下にボタンを配置しようとしています。私はこれを行い、異なるスクリーンサイズに渡って同じ相対レイアウトを維持したいと思っています。現在、画面上のボタンは、画面の解像度に応じて上下に移動します。 320x480は、画面上のボタンを480x800よりも高くします。 2つのサイズの画面が同じに見えるようにしようとしています。AndroidボタンをRelativeLayoutのボトムに合わせるには?

+1

xmlを表示する必要があります。 – Falmarri

+0

[RelativeLayoutの一番下にRelativeLayoutを配置する方法]の複製が可能ですか?(http://stackoverflow.com/questions/3492721/how-to-place-a-relativelayout-at-the-bottom-of-a -relativelayout) – rds

答えて

3

あなたはandroid:layout_alignParent *を使用していますか?それは画面の大きさにかかわらず側面にそれを正当化するはずです。

* AedonEtLIRAあなたは必ずRelativeLayoutを使用すると、表示領域全体を常に満たされていることを確認する必要があり言っほかの一番下または上または左または右

3

です。すなわち、ビュー階層内の任意の場所に定義されたサイズはありませんが、代わりにmatch_parentが使用されます。あなたがAedonEtLIRAによって与えられたレイアウト定義を使用したならば、あなたが望むものを正確に得るべきです。

2

例:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:panel="http://schemas.android.com/apk/res/it.kronplatz" 
    android:id="@+id/MainLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <RelativeLayout 
     android:id="@+id/ButtonLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_centerHorizontal="true" 
     android:baselineAligned="false" > 

     <ImageButton 
      android:id="@+id/locateMeButton" 
      android:layout_width="70px" 
      android:layout_height="70px" 
      android:layout_marginLeft="5px" 
      android:src="@drawable/me" > 
     </ImageButton> 

     <ImageButton 
      android:id="@+id/MapCenterButton" 
      android:layout_width="70px" 
      android:layout_height="70px" 
      android:layout_alignParentRight="true" 
      android:layout_gravity="right" 
      android:layout_marginRight="5px" 
      android:src="@drawable/fadenkreuz_klein" /> 

     <Button 
      android:id="@+id/MapNextButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:drawableRight="@drawable/androidmarker" > 
     </Button> 
    </RelativeLayout> 

</RelativeLayout> 
34

私は、これは古いスレッドです知っているが、私はそれが

android:layout_alignParentBottom="true" 

がのために働いていることを確認するために傷つけることはできません理解して、それは、検索結果の一番上に現れますRelativeLayoutで私。

関連する問題