Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何在相对布局(android)中并排获得两个字段?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道你可以使用权重参数进行线性布局,以使两个字段很好地对齐.我想要做的是我想确保屏幕的左半部分由一个文本字段使用,另一半用于其他文本字段(我在谈论宽度).
怎么办?

解决方法

在中心使用没有高度或宽度的“隐藏视图”,并在两侧放置文本视图.使用父对齐设置左右.

<RelativeLayout 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content">

   <View android:id="@+id/dummy"
       android:layout_height="0dp" 
       android:layout_width="0dp"
       android:layout_centerInParent="true"/>

   <TextView
       android:layout_alignRight="@id/dummy"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_alignParentLeft="true"/>

   <TextView
       android:layout_alignLeft="@id/dummy"
       android:layout_height="wrap_content"
       android:layout_width="wrap_content"
       android:layout_alignParentright="true"/>

</RelativeLayout>

大佬总结

以上是大佬教程为你收集整理的如何在相对布局(android)中并排获得两个字段?全部内容,希望文章能够帮你解决如何在相对布局(android)中并排获得两个字段?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。