控件布局心得

2015/8/26问题集

让控制置于底部

android 让一个控件按钮居于底部的几种方法

  • 1.采用linearlayout布局:
    android:layout_height=”0dp” !— 这里不能设置fill_parent —>
    android:layout_weight=”1” !— 这里设置layout_weight=1是最关键的,否则底部的LinearLayout无法到底部 —>

  • 2:采用relativelayout布局:
    android:layout_alignParentBottom=”true” !— 这里设置layout_alignParentBottom=true是最关键的,这个属性上级必须是RelativeLayout —>

  • 3: 采用 fragment 布局(activitygroup 已经被弃用不建议使用)

http://www.cnblogs.com/zdz8207/archive/2012/12/13/2816906.html

与底部之间的距离

这个要设置在布局文件中(learnlayout之类的)

android:layout_marginBottom="100dp"

将控件底部与父类底部对齐

android:layout_alignParentBottom="true"

将控件底部与父类右边对齐

android:layout_alignParentRight="true"

相对布局中居中对齐

android:layout_centerHorizontal="true"