首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

RelativeLayout布局的一些尴尬,该如何处理

2012-03-14 
RelativeLayout布局的一些尴尬Java code?xml version1.0 encodingutf-8?RelativeLayout xmlns:an

RelativeLayout布局的一些尴尬

Java code
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:background="@drawable/ic_click"    android:minHeight="66dip" >    <TextView        android:id="@+id/newstitle"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:paddingLeft="11.3dip"        android:paddingRight="52dip"        android:paddingTop="14dip"        android:textColor="@color/black"        android:textSize="@dimen/middleTextSize"        android:textStyle="bold" >    </TextView>    <TextView        android:id="@+id/newsaddTime"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignLeft="@+id/newstitle"        android:layout_below="@+id/newstitle"        android:paddingLeft="11.3dip"        android:paddingTop="8.6dip"        android:textColor="@color/black"        android:textSize="@dimen/smallTextSize" >    </TextView>    <ImageView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentRight="true"        android:layout_centerVertical="true"        android:layout_marginRight="5.3dip"        android:src="@drawable/ic_arrow" >    </ImageView></RelativeLayout>

这个布局是@+id/newsaddTime本来应该在@+id/newstitle下面的,但实际显示的时候@+id/newsaddTime没有在@+id/newstitle的下面,而是默认在Relativelayout布局的顶端,感觉好奇怪,求大家帮忙看看

[解决办法]
楼主有木有经过测试啊,怎么我把你的布局放进我的程序里一测,发现@+id/newsaddTime确实在@+id/newstitle下面??
[解决办法]
有可能是你的大布局影响到了你的这个,你把你贴的代码直接拷进另外一个单独的xml里测试一下看看,如果发现结果正确,表示你的大布局有问题啊.
我自己测试了一下,确定没有你说的问题.
[解决办法]
楼主把 newsaddTime 的
android:layout_alignLeft="@+id/newstitle"
android:layout_below="@+id/newstitle"
两个 +号 去掉试试


android:layout_alignLeft="@id/newstitle"
android:layout_below="@id/newstitle"

[解决办法]
探讨

有可能是你的大布局影响到了你的这个,你把你贴的代码直接拷进另外一个单独的xml里测试一下看看,如果发现结果正确,表示你的大布局有问题啊.
我自己测试了一下,确定没有你说的问题.

[解决办法]
Java code
<TextView        android:id="@+id/newsaddTime"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignLeft="@+id/newstitle"        android:layout_below="@+id/newstitle"  //把加号去掉看看        android:paddingLeft="11.3dip"        android:paddingTop="8.6dip"        android:textColor="@color/black"        android:textSize="@dimen/smallTextSize" >    </TextView>
[解决办法]
android:layout_alignLeft="@+id/newstitle"楼主去掉这条语句看看呢
[解决办法]
android:layout_alignLeft="@+id/newstitle"
这句要去掉,这应该是默认在newstitle左边了


[解决办法]
ID前有加号表示新ID,没加号表示引用其他ID指定的对象,应该是这样吧。

热点排行