一、概述
在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 installd分析
  2. Android布局属性详解
  3. Android(安卓)关于WebView的相关属性
  4. android.inputmethodservice.KeyboardView 自定义键盘 字体大小
  5. android布局layout中的一些属性
  6. android布局layout中的一些属性
  7. Android局部布局替换实现
  8. Android动画学习笔记-Android(安卓)Animation
  9. android学习之LinearLayout

随机推荐

  1. Android(安卓)SDK下载项的说明
  2. Android(安卓)DataBinding 使用指南
  3. android aidl出现无法import
  4. Android开机画面修改
  5. android tabhost 图标
  6. android定时器Timer与TimerTask
  7. Android(安卓)OpenGL ES 读书笔记(1)
  8. Android中的国际化
  9. Android仿微信录制语音
  10. Android(安卓)Intent Activity 跳转几种