求帮忙解释下,为什么LinearLayout在FrameLayout下面就会固定到底部

Android 码拜 8年前 (2016-06-04) 812次浏览
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </FrameLayout>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="?attr/colorPrimary" >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="abc"/>
</LinearLayout>

刚学android,想做一个tab选项卡,问一下下,为什么LinearLayout 放在FrameLayout,并且设置android:layout_weight=”1″以后就被固定到底部了,网上看了很多关于FrameLayout布局还是没看明白。

解决方案

20

你的linearlayout本身就在framelayout下面,并且指定了固定高度,然后framelayout又设置了Layout_weight属性
所以linearlayout占用了最下面的70dp的高度,剩余的屏幕都属于framelayout了

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求帮忙解释下,为什么LinearLayout在FrameLayout下面就会固定到底部
喜欢 (0)
[1034331897@qq.com]
分享 (0)