2011-01-12 76 views
10

我想使用RelativeLayout将按钮对齐屏幕的右下角和左下角。我想要做到这一点,以保持不同屏幕尺寸的相同布局。目前,屏幕上的按钮会根据屏幕的分辨率向上/向下移动。 320x480将屏幕上的按钮放大到480x800。我试图让我的屏幕在两种尺寸之间看起来一样。将Android Button调整到RelativeLayout的底部?

+1

您将不得不向我们展示您的xml。 – Falmarri 2011-01-12 22:00:15

回答

3

你使用的是android:layout_alignParent *?无论屏幕大小如何,这都应该证明这一点。

其中*底部或顶部或左或右

3

在加入什么AedonEtLIRA说你应该确保在RelativeLayout的你一直充满了整个显示区域。即。您没有在视图层次结构中的任何位置定义任何大小,而是使用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中。

相关问题