在RelativeLayout中将Android按钮对齐到底部?

Mob*_*now 13 android button alignment

我正在尝试使用RelativeLayout将按钮对齐到屏幕的右下角和左下角.我想这样做是为了在不同的屏幕尺寸上保持相同的相对布局.目前,我的屏幕上的按钮根据屏幕的分辨率向上/向下移动.320x480将按钮设置在屏幕上,而不是480x800.我试图让我的屏幕在两种尺寸之间看起来一样.

Cas*_*ray 41

我知道这是一个旧线程,但它显示在搜索结果的顶部,所以我认为确认这一点不会有什么坏处

android:layout_alignParentBottom="true"  
Run Code Online (Sandbox Code Playgroud)

在RelativeLayout为我工作.


aho*_*der 5

您在使用android:layout_alignParent *吗?无论屏幕大小如何,这都应该证明它是正确的。

*是底部或顶部或左侧或右侧


fmo*_*fmo 5

例子:

<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>
Run Code Online (Sandbox Code Playgroud)