方法一:

<RelativeLayout android:id="@+id/relativeTop"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
> <Button
android:id="@+id/btnGetMp3s"
android:text="@string/strGetMp3List"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_toLeftOf="@id/txtHide"
/>
<TextView android:id="@+id/txtHide" android:layout_width="25" android:layout_height="1"
android:layout_centerHorizontal="true" />
<Button
android:id="@+id/btnExitSys"
android:text="@string/strExitSys"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/txtHide" />
</RelativeLayout>

方法二:

<LinearLayout android:layout_width="fill_parent"

                android:layout_height="wrap_content"

                android:orientation="horizontal"

                style="@android:style/ButtonBar"

                >

                <Button android:id="@+id/btn_listview"

                    android:layout_height="wrap_content"

                    android:layout_width="0dp"

                    android:layout_weight="1"

                    android:text="ListView"/>

                <Button android:id="@+id/btn_emptyview"

                    android:layout_height="wrap_content"

                    android:layout_width="0dp"

                    android:layout_weight="1"

                    android:text="EmptyView"/>      

            </LinearLayout>

从零开始学android-一行两个按钮居中 布局的更多相关文章

  1. 从零开始学android -- Service

    废话不多说了,Service是四大组件之一,是一个后台处理长时间运行在主线程不需要依赖ui界面显示的应用组件,切记不能在service中做耗时操作,会阻塞主线程,要做也要在service中开个子线程做 ...

  2. 第24章、OnLongClickListener长按事件(从零开始学Android)

    在Android App应用中,OnLongClick事件表示长按2秒以上触发的事件,本章我们通过长按图像设置为墙纸来理解其具体用法. 知识点:OnLongClickListener OnLongCl ...

  3. 从零开始学android开发- layout属性介绍

    android:id 为控件指定相应的ID android:text 指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串 android:gravity 指定Vi ...

  4. 从零开始学android开发-布局中 layout_gravity、gravity、orientation、layout_weight

    线性布局中,有 4 个及其重要的参数,直接决定元素的布局和位置,这四个参数是 android:layout_gravity ( 是本元素相对于父元素的重力方向 ) android:gravity (是 ...

  5. 从零开始学android开发- 应用程序窗体显示状态操作requestWindowFeature

    我们在开发程序是经常会需要软件全屏显示.自定义标题(使用按钮等控件)和其他的需求,今天这一讲就是如何控制Android应用程序的窗体显示. 首先介绍一个重要方法那就是requestWindowFeat ...

  6. 从零开始学android开发-四大组件之一 Activity

    1.Activity是Android四大组件(Application Components)之一,简单来说Activity就是平常所见到的用户界面,一般情况下,一个Activity所占的窗口是满屏的, ...

  7. 从零开始学android开发-详细谈谈intent的startActivityForResult()方法

    1.两种实现activity跳转的方法 实现activity的跳转主要有两种方法,startActivity()和startActivityForResult();例如activity A跳转到act ...

  8. 从零开始学android -- 简易的socket通信

    先来介绍下socket,网上摘抄点资料,免得自己打字了 网络中进程之间如何通信? 本地的进程间通信(IPC)有很多种方式,但可以总结为下面4类: 1.消息传递(管道.FIFO.消息队列) 2.同步(互 ...

  9. 从零开始学android开发-项目打包发布

    右键项目 选择[android tools]-[export signed application package] 点击[next] 如果没有keystore可以选择[create new keys ...

随机推荐

  1. 【HDOJ】1699 The comment in cpp

    注意测试数据12/*hduacm// abcd结果是1/*hduacm// ABCD /* 1699 */ #include <iostream> #include <sstream ...

  2. freemarker截取字符串

    [#if   a.title?length   lt   23   ]   ${a.title} [#else]${a.title[0..22]}...[/#if]

  3. poj2373

    其实这道题不是很难,不难想到f[i]表示覆盖到[0,i]的最少喷头数 很明显是一个dp+单调队列的问题 但是细节问题比较多,首先是不能覆盖到[0,l]外面,所以长度为奇数不能被完全覆盖 还有一些区间[ ...

  4. light开发框架

  5. Xcode7下载地址

    XCode 7 7.3.1:https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_7.3. ...

  6. 查看各个release版本 golang的改动

    https://golang.org/doc/go1.1 https://golang.org/doc/go1.2 https://golang.org/doc/go1.3 https://golan ...

  7. POJ 1017 Packets

    题意:有一些1×1, 2×2, 3×3, 4×4, 5×5, 6×6的货物,每个货物高度为h,把货物打包,每个包裹里可以装6×6×h,问最少几个包裹. 解法:6×6的直接放进去,5×5的空隙可以用1× ...

  8. C#中数据类型的安全转换(is,as)

    原文 C#中数据类型的安全转换(is,as) 下面代码中,不能装箱,在强制类型转换时出错,因为之前 c 是 class 类型,而却要把它转换为 int 类型,这是不可以的.虽然编译器能通过编译,但是 ...

  9. VBScript: Windows脚本宿主介绍

    Windows脚本宿主(Windows Script Host, WSH)是一个Windows管理工具.WSH创建了一个脚本运行的主环境,WSH使脚本能够使用对象和服务,并提供脚本执行的准则.WSH还 ...

  10. 初涉C#防止黑客攻击站短

    一.同一个IP如果在一分钟内连续发送5个站短可以认为是不正确的,原因有2方面: 1.发站短的页面是有点击按钮,点击按钮后马上按钮会变为不可点击,所以在前端要防止点击一次触发多次的情况 2.发送短信的U ...