本文转自:http://www.cnblogs.com/zdz8207/archive/2012/12/13/2816906.html

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 已经被弃用不建议使用) =====================================
1.采用linearlayout布局:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"> <LinearLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="0dp" <!-- 这里不能设置fill_parent -->
android:layout_weight="1" <!-- 这里设置layout_weight=1是最关键的,否则底部的LinearLayout无法到底部 -->
android:orientation="vertical"> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/runbackground"
android:focusable="false" />
</LinearLayout>
</LinearLayout> 2. 采用relativelayout布局:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"> </LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" <!-- 这里设置layout_alignParentBottom=true是最关键的,这个属性上级必须是RelativeLayout -->
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/runbackground"
android:focusable="false" />
</LinearLayout>
</RelativeLayout> 3. 采用 fragment 布局(activitygroup 已经被弃用不建议使用)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <fragment class="com.xuzhi.fragment.FragmentDemoActivity$TitlesFragment" android:id="@+id/titles" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent"
/> <FrameLayout android:id="@+id/details" android:layout_weight="1" android:layout_width="0px" android:layout_height="match_parent"
android:background="?android:attr/detailsElementBackground"
></FrameLayout> </LinearLayout>

[转]android 让一个控件按钮居于底部的几种方法的更多相关文章

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

    android 让一个控件按钮居于底部的几种方法1.采用linearlayout布局:android:layout_height="0dp" <!-- 这里不能设置fill_ ...

  2. [Android] Android 让UI控件固定于底部的几种方法

    Android 让UI控件固定于底部的几种方法1.采用linearlayout布局:android:layout_height="0dp" <!-- 这里不能设置fill_p ...

  3. 给Repeater控件里添加序号的5种方法

    Repeater是我们经常用的一个显示数据集的数据控件,经常我们希望在数据前显示数据的序号,那么我们该怎么为Repeater控件添加序号呢?下面编辑为大家介绍几种常用的为Repeater控件添加序号的 ...

  4. 利用来JS控制页面控件显示和隐藏有两种方法

    利用来JS控制页面控件显示和隐藏有两种方法,两种方法分别利用HTML的style中的两个属性,两种方法的不同之处在于控件隐藏后是否还在页面上占空位. 方法一:  1 2 document.getEle ...

  5. Android自己定义控件:进度条的四种实现方式

    前三种实现方式代码出自: http://stormzhang.com/openandroid/2013/11/15/android-custom-loading/ (源代码下载)http://down ...

  6. delphi xe6 for android 自带控件LocationSensor优先使用GPS定位的方法

    delphi xe6 for android LocationSensor控件默认是优先使用网络定位,对定位精度要求高的应用我们可以修改原码直接指定GPS定位. 修改方法: 将C:\Program F ...

  7. Java学习笔记——可视化Swing中JTable控件绑定SQL数据源的两种方法

    在 MyEclipse 的可视化 Swing 中,有 JTable 控件. JTable 用来显示和编辑常规二维单元表. 那么,如何将 数据库SQL中的数据绑定至JTable中呢? 在这里,提供两种方 ...

  8. QT 窗体控件的透明度设置(三种方法)

    整个窗体 当设置QT的窗体(QMainWindow, QDialog)时,直接用 targetForm->setWindowOpacity()   函数即可实现,效果为窗体及窗体内所有控件都透明 ...

  9. 解决swfupload上传控件文件名中文乱码问题 三种方法 flash及最新版本11.8.800.168

    目前比较流行的是使用SWFUpload控件,这个控件的详细介绍可以参见官网http://demo.swfupload.org/v220/index.htm 在使用这个控件批量上传文件时发现中文文件名都 ...

随机推荐

  1. [luoguP3052] [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper(DP)

    传送门 输出被阉割了. 只输出最少分的组数即可. f 数组为结构体 f[S].cnt 表示集合 S 最少的分组数 f[S].v 表示集合 S 最少分组数下当前组所用的最少容量 f[S] = min(f ...

  2. 简单svg动画

    一.将svg嵌入到html中 svg是指可伸缩矢量图形,它使用XML格式定义图像.在html中可以使用<svg>标签直接嵌入svg代码,例如: <svg version=" ...

  3. 实例:Mongodb集群配置过程

    最近因为一些项目公司开始采用Mongodb做为大量的数据存储,通过网络上大量的资源自己已经掌握一套可行的Mongodb集群配置过程,Mongodb具有无规则存储.大数据存储.多平台支持.强大的扩展插件 ...

  4. 《Spring in action》之Spring之旅

    Spring框架作用是简化java开发的复杂性.下面是spring in action 对spring初步介绍. 一.主要有4种关键策略: 1. 基于POJO的轻量级和最小侵入性编程 . 2. 通过依 ...

  5. ZFS

    zfs是128bit文件系统,那么为什么容量是2^64byte? 不应该是2^128 / 2^3=2^125 byte吗 文件系统不再局限于单独的物理设备,而且文件系统还允许物理设备把他们自带的那些文 ...

  6. centos 7: 迁移MySQL目录

    Steps: 1. systemctl stop mariadb 2. mkdir data destination folder, ex: /home/mysql 3. cp -R /var/lib ...

  7. stl空间配置器alloc

    new运算包含两阶段操作: 1) 调用::operator new分配内存     2) 调用构造函数构造对象内容 delete运算包含两阶段操作: 1)调用析构函数将对象析构    2)调用::op ...

  8. shell中的四种模式匹配

    POSIX为shell为进行模式匹配提供了四种参数替换结构(老版本的shell可能不支持),每种结构有两个参数:变量名(或变量号)及模式. 第一种模式:    ${variable%pattern}, ...

  9. 1. FrogRiverOne 一苇渡江 Find the earliest time when a frog can jump to the other side of a river.

    package com.code; public class Test04_3 { public static int solution(int X, int[] A) { int size = A. ...

  10. STL 笔记(五) 算法 algorithm

    在 STL 中,算法是一系列的函数模版.STL 提供了大概 70 个算法,由头文件 <algorithm>.<numeric>.<functional>组成. 头文 ...