一、概述
在LinearLayout布局下,对Bottom添加属性 layout_gravity="bottom" 失效。[xhtml] view plain copy

<?xml version="1.0" encoding="utf-8"?>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:text="Button"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">

我觉得原因是LinearLayout 是竖直排列widgets的布局,所以竖直方向上有可能同时存在多个widgets。如果有两个或两个以上的widgets设置了android:layout_gravity="bottom"属性,那么系统就不能分辨出到底哪个widget放置在底部。所以在LinearLayout的vertical布局下,android:layout_gravity="bottom"无效。

二、解决方法
可以通过RelativeLayout布局android:layout_alignParentBottom="true"来实现放置底部效果。[xhtml] view plain copy

<?xml version="1.0" encoding="utf-8"?>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/ProcessBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Process">

更多相关文章

  1. Android 关于WebView的相关属性
  2. Android局部布局替换实现
  3. RecylcerView中的子view matchParent属性失效的问题
  4. 【Android】Android中 Paint 字体、粗细等属性的一些设置
  5. 安卓笔记:安卓控件属性大全
  6. android layout属性 .
  7. Attribute is missing the Android namespace prefix——android

随机推荐

  1. 2.4简单的按钮----Android(安卓)Button
  2. Android(安卓)Transition框架介绍及使用
  3. Android(安卓)JNI输出LOG
  4. Android学习之使用SAX解析xml文件
  5. android data binding
  6. 使用react-native做一个简单的应用-03欢迎
  7. android实现网络防火墙控制app访问wifi/
  8. Android-使用HttpURLConnection实现多线
  9. ARM DS-5安装及使用(android)
  10. 如何让Android程序支持安装到SD卡(APP2SD)