当相对布局,出现模拟器渲染的位置和设置的位置(正确的)不一样时,有时可以将其宽或高强制写死。
demo:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="240dp" >
<com.zh.zhbj.view.TabNewsViewPager
android:id="@+id/vp_news"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#9000"
android:padding="5dp" >
<TextView
android:id="@+id/tv_bttom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新闻标题"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
本文介绍了一种在Android开发中解决相对布局元素位置偏差的方法,通过将某些元素的高度强制设定为具体数值,确保了模拟器渲染效果与预期一致。
2721

被折叠的 条评论
为什么被折叠?



