
我有一个ListVIEw,其中包含由relativeLayouts组成的项目.这是列表项中的相关XML:
<?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"> <TextVIEw androID:ID="@+ID/xx" androID:gravity="center_vertical" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="center_vertical" androID:layout_centerInParent="true" androID:layout_alignParentleft="true"/> <TextVIEw androID:ID="@+ID/Title" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_toRightOf="@ID/xx" /> <TextVIEw androID:ID="@+ID/tag" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_toRightOf="@ID/xx" androID:layout_below="@ID/Title" /> <TextVIEw androID:ID="@+ID/subTitle" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_toRightOf="@ID/tag" androID:layout_below="@ID/Title" /></relativeLayout>在AndroID 2.1(在Nexus One上测试)中,这显示了所需的行为:Android 1.5 http://img42.imageshack.us/img42/7668/85324076.png
然而,在AndroID 1.5上(在HTC Hero上测试过),它显示如下:Android 1.5 http://img257.imageshack.us/img257/2849/72229324.png
[编辑]在1.6(模拟器)上,它也按预期工作.
左上角的小灰线是第一张照片中显示的“xx”,因此它应该是垂直居中的.据我所知,XML决定了这一点,但由于某种原因,1.5忽略了它.
为什么是这样?我找不到任何关于这种差异的东西,而且我已经粗暴地强迫layout_center,center,alignParent *的任何组合,但无济于事……
任何人都可以对此有所了解吗?谢谢!
解决方法:
对于相对布局,不使用layout_gravity.
此外,您正在使用冲突的属性centerInParent和alignParentleft.
只使用其中一个.
你可以使用layout_centerVertical =“true”layout_alignParentleft =“true”
总结以上是内存溢出为你收集整理的android – RelativeLayout在1.5和2.1之间的差异全部内容,希望文章能够帮你解决android – RelativeLayout在1.5和2.1之间的差异所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)