Android -如何在底部左对齐,中对齐,右对齐三个按钮图片 巧用Relative Layout
Relative Layout 不仅可以指定同级的元素之间的位置关系(e.g. layout_toLeftOf) 还可以指定子元素与父元素之间的位置关系(e.g. layout_alignParentLeft 相对于父元素左对齐) 利用这一点,可以轻松实现图片在屏幕底部对齐显示。

代码如下:
<?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="match_parent"
android:orientation="vertical"
android:divider="@drawable/line"
android:showDividers="middle"> <!--新闻内容 -->
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"> </WebView> <!--底部图片-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
> <ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_alignParentLeft="true"<!--在父元素中左对齐 -->
android:background="@drawable/back" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_centerInParent="true"<!--在父元素中居中对齐 -->
android:background="@drawable/house" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/share"
android:layout_alignParentRight="true" <!--在父元素中右对齐 -->
android:layout_marginRight="10dp"
android:layout_gravity="center_horizontal"
/> </RelativeLayout> </LinearLayout>
Android -如何在底部左对齐,中对齐,右对齐三个按钮图片 巧用Relative Layout的更多相关文章
- LI 标签中让文章标题左对齐,日期右对齐的方法
希望实现标题在左对齐,日期在右对齐,当直接给日期的span加上float:right时,IE8和FF都OK,但IE6/7则会换行,下面给出一个简单有效的解决办法. <!DOCTYPE html ...
- LinearLayout中组件右对齐
在LinearLayout中,如果将其定位方向设为横向排列:android:orientation="horizontal",那么这个布局中的控件将自左向右排列. 但有时会有这样的 ...
- [No000089]String的(补空位)左对齐,(补空位)右对齐
using System; namespace Chinese中文排序Sort { internal class Program { /// <summary> /// 取子字符串 /// ...
- DIV左、中、右三列布局的各类情况说明
一.中间定宽.左.右侧百分比自适应: 1.HTML代码: <div id="left"> <div id="innerLeft"> &l ...
- form中label标签对齐,内容右对齐
给label设置一个固定长度即可: label{ display:inline-block; width:100px; text-align:right; }
- GitHub中"watch" "star" "fork"三个按钮干什么用的?
总结下一般使用:1.想拷贝别人项目到自己帐号下就fork一下.2.持续关注别人项目更新就star一下3.watch是设置接收邮件提醒的.具体提醒有Issues and their commentsPu ...
- 音频采样中left-or right-justified(左对齐,右对齐), I2S时钟关系
音频采样中left-or right-justified(左对齐,右对齐), I2S时钟关系 原创 2014年02月11日 13:56:51 4951 0 0 刚刚过完春节,受假期综合症影响脑袋有点发 ...
- 转-安卓中实现两端对齐,中间fill_parent的方法
安卓中实现两端对齐,中间fill_parent的方法 Java代码: <?xml version="1.0″ encoding="utf-8″?> <Line ...
- 通过代码设置button中文字的对齐方式
// button.titleLabel.textAlignment = NSTextAlignmentLeft; 这句无效 button.contentHorizontalAlignment = U ...
随机推荐
- makefile、gdb使用记录
makefile的模板 all: rover server station rover: rover.c tcputil.o gcc rover.c tcputil.o -o rover -lpthr ...
- arduino图形化编程——ardublock
下载地址:http://sourceforge.net/projects/ardublock/ 项目主页:https://github.com/taweili/ardublock 运行效果图 ardu ...
- 第三百零一天 how can i 坚持
其实真搞不大懂自己.不喜欢巴结人,也不喜欢阿谀奉承,但老是感觉自己却又在那么做,是对自己要求太高了,想太多?? 郭娜好像把我拉黑了,拉黑就拉黑吧.或许真不合适. 睡觉.
- HDU 5510 Bazinga (2015沈阳现场赛,子串判断)
Bazinga Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- Gradle – Spring 4 MVC Hello World Example – Annotation
In this tutorial, we will take the previous Gradle + Spring MVC XML example, rewrite it to support @ ...
- jquery easyui的扩展验证
1.扩展通过$.extends($.fn.validatebox.defaults.rules,)扩展 $.extend( $.fn.validatebox.defaults.rules, { idc ...
- jQuery基础学习8——层次选择器next()和prev()方法
$('.one + div').css("background","#bbffaa"); //和next()方法是等价的,前后关系,和prev()方法是对立的 ...
- substr函数
substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H' *从字符串第一个字符开始截取长度为1的字符串 subst ...
- 转载github上最全的资源教程--前端涉及的所有知识体系
以下地址为园子里一个哥们总结的前端所涉及的所有知识体系 http://www.cnblogs.com/bymax/p/5878113.html 很值得学习参考
- Umbraco 上传文件到另一个文件夹,而不是media files
If you want to upload there media files to another place in the same instance of IIS, for example a ...