簡體   English   中英

RelativeLayout的重力底端?

[英]RelativeLayout gravity bottom?

我正在嘗試使用RelativeLayout將gravity降至最低。 當我使用android:gravity="bottom"它不會在底部對齊。

我該怎么辦?

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fundo"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_margin="10dp">
        <ImageView
            android:layout_margin="10dp"
            android:padding="10dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/logo"/>
    </LinearLayout>


    <!-- Control -->
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:orientation="vertical"
        android:gravity="bottom">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="@drawable/bar_bot_player"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="-20dp"
            android:orientation="horizontal"
            android:gravity="center"
            android:weightSum="1">
            <ImageButton
                android:id="@+id/btPlay"
                android:layout_width="50dp"
                android:background="@drawable/btnplay"
                android:gravity="center"
                android:layout_height="wrap_content" />

            <ImageButton
                android:id="@+id/btStop"
                android:visibility="gone"
                android:layout_width="50dp"
                android:background="@drawable/stop"
                android:gravity="center"
                android:layout_height="wrap_content" />
        </LinearLayout>

    </RelativeLayout>


</LinearLayout>

這樣做

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fundo">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_margin="10dp" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:padding="10dp"
            android:src="@drawable/logo" />
    </LinearLayout>

    <!-- Control -->

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:layout_alignParentBottom="true"
        android:gravity="bottom">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="@drawable/ic_launcher" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="-20dp"
            android:gravity="center"
            android:orientation="horizontal"
            android:weightSum="1" >

            <ImageButton
                android:id="@+id/btPlay"
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:background="@drawable/btnplay"
                android:gravity="center" />

            <ImageButton
                android:id="@+id/btStop"
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:background="@drawable/stop"
                android:gravity="center"
                android:visibility="gone" />
        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM