</pre><pre class="java" name="code"><RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<com.jinsu.aiqiyue.CircleImageView
android:id="@+id/civ_mine_gerenziliao"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_marginLeft="10dip"
android:layout_marginBottom="10dip"
android:src="@drawable/morentu" />
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_below="@+id/civ_mine_gerenziliao"/>
<TextView
android:id="@+id/tv_mine_ziliao_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Amy"
android:textColor="#FFFFFF"
android:layout_alignBottom="@+id/civ_mine_gerenziliao"
android:layout_toRightOf="@+id/civ_mine_gerenziliao"
android:textSize="20sp" />
</RelativeLayout>
什么也不说了 先上代码,经常用相对布局的伙伴会发现 如果你设置了android:layout_alignParentBottom="true"这条属性之后,那么你会发现里面的控件 使用marginBottom没有任何效果了,但是如果你加上上面代码中view控件,你的使用又正常了,神奇吧,我也不知道原理,实用就足够啦
<RelativeLayout
xmlns:
android
="http://schemas.
android
.com/apk/res/
android
"
android
:layout_width="fill_parent"
android
:layout_height="fill_parent">
<ImageView
需要在下面添加
布局
,如下:
<RelativeLayout
xmlns:
android
="http://schemas.
android
.com/apk/res/
android
"
android
:layout_width="fill_parent
Android
开发中,我们经常利用xml来设置控件layout_
marginBottom
属性的值,那么,如何在java代码中设置这个属性呢?
这样的目的是,实现动态修改UI,而不需要重新定义
布局
文件。
样例如下:首先,来看xml的定义(截取一部分):<ListView
android
:id="@+id/listview"
android
:layout_width="fill_
layout_marginTop,layout_
marginBottom
,layout_marginRight,layout_marginLeft 是 RelativeLayout 中的四种属性,今天在进行UI设计的时候,着实困扰了好久,索性做个总结。
先上结论:
layout_marginTop 指定该属性所在控件距上部最近控件的最小值;
layout_
marginBottom
...
我的方法:
如在下面的xml中,我想设置Button 距离屏幕底部的距离为90dp;
1. 写一个没有内容的TextView,设置属性为layout_alignParentBottom="true",将其高度设置为 90dp;
2.在Button中设置
android
:layout_alignTop="@+id
当RelativeLayout的view设置了layout_alignParentBottom属性以后,该view的layout_
marginBottom
会
不起作用
。或者其他的一些属性
不起作用
的时候,就需要在该view的外面再加一层layout才起作用。创建一个layout具有一下属性,然后在里面添加view。。
android
:id="@+id/gap"
android
:layout_wi
发现显示异常,如图:
布局
代码如下:
<RelativeLayout xmlns:
android
="http://schemas.
android
.com/apk/res/
android
"
android
:layout_width="280dp"
android
:layout_height="
paddingBottom 是指控件中内容距离控件底边距离。比如:Button高10dp,宽10dp,将paddingBottom =10dp,那么Button高就变为20dp,Button内容靠上显示,距离底边10dp。
layout_
marginBottom
是指控件边以外空下的距离,比如Button1和Button2垂直显示,将Button1中layout_marginBotto...
1.LinearLayout中,将某一组件或
布局
放置于底部
<LinearLayout xmlns:
android
="http://schemas.
android
.com/apk/res/
android
"
android
:id="@+id/background"
android
:layout_width="match_parent"
android
:layout_hei