简体   繁体   中英

layout_alignParentBottom in Linear Layout

Can any one help me . I need a button at the bottom of the screen. For relative layout layout i can use

android:layout_alignParentBottom="true"

But what to use if i am using linear layout. Please help

you can try something like this

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="0dp"
     android:layout_weight="1.0">
    </LinearLayout>
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Button">
    </Button>
</LinearLayout>
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:gravity="bottom">

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Button"/>

    </LinearLayout>

在 (LinearLayout) 中使用 (RelativeLayout),然后在 (RelativeLayout) 中添加 (android:layout_alignParentBottom="true")。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM