码迷,mamicode.com
首页 > 移动开发 > 详细

android-LinearLayout 控件居于底部

时间:2015-01-24 15:47:01      阅读:1560      评论:0      收藏:0      [点我收藏+]

标签:

经常碰到需要把一个控件放在手机底部的情况,以前都是在LinearLayout尝试使用gravity="bottom" ,但是,没有效果,后来在网上查到了方法,如下

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

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginEnd="12dp"
        android:layout_marginTop="12dp"
        android:textSize="15sp"
        android:textColor="#323232"
        android:text="@string/master_clear_final_desc" />
<!--这个是关键,就是占满次下屏幕的所有位置-->
     <LinearLayout android:id="@+id/content" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> </LinearLayout> <Button android:id="@+id/execute_master_clear" style="@style/SecurityPreferenceButtonFunuiConfirm" android:text="@string/master_clear_final_button_text" /> </LinearLayout>

至于android:layout_height="0dp" android:layout_weight="1" 的搭配使用,一直有点疑惑,不知道到底什么作用,以后会留意的,反正这个能实现让execute_master_clear局底部

android-LinearLayout 控件居于底部

标签:

原文地址:http://www.cnblogs.com/zhangshuli-1989/p/zhangshuli_zj_15012414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!