【问题标题】:Android Align LinearLayout at Bottom not WorkingAndroid在底部对齐LinearLayout不起作用
【发布时间】:2016-04-10 12:16:18
【问题描述】:

我有这个 LinearLayout,其中是一个地图片段,这一切都有效,但由于某种原因,我无法让线性布局与屏幕底部对齐。这是我的xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"
    android:baselineAligned="false"
    android:weightSum="1"
    android:background="@mipmap/background_colour">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="30dp"
        android:layout_height="31dp"
        android:weightSum="1"
        android:id="@+id/back_button"
        android:background="@drawable/navigation_back"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="10dp">

    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.31">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Large Text"
            android:id="@+id/textView7" />
    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.30">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Large Text"
            android:id="@+id/textView6" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/lay"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="wrap_content"
        android:layout_weight="3.5">



    </LinearLayout>
    </LinearLayout>

我要对齐的 LinearLayout 是 id: "lay" one。

【问题讨论】:

    标签: java android xml fragment


    【解决方案1】:

    我找到了解决办法:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity"
        android:baselineAligned="false"
        android:weightSum="1"
        android:background="@mipmap/background_colour">
    
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="30dp"
            android:layout_height="31dp"
            android:weightSum="1"
            android:id="@+id/back_button"
            android:background="@drawable/navigation_back"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="10dp">
    
        </LinearLayout>
    
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="177dp">
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Large Text"
                android:id="@+id/textView7" />
        </LinearLayout>
    
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="146dp">
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Large Text"
                android:id="@+id/textView6" />
        </LinearLayout>
    
        <LinearLayout
            android:id="@+id/lay"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"
            android:layout_height="match_parent">
    
    
    
    </LinearLayout>
    </LinearLayout>
    

    【讨论】:

      最近更新 更多