
我试图将TextVIEw对齐在相对布局中,但也在ImageVIEw的右侧.我希望它看起来像这样.
[-(image)-----some text here------------]我可以使用下面的代码执行此 *** 作,但如果文本变得太长,则会与图像重叠.
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="horizontal" androID:paddingtop="@dimen/small_padding" androID:paddingBottom="@dimen/small_padding" androID:background="@color/White"> <ImageVIEw androID:ID="@+ID/navMenu" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/home_icon" androID:layout_marginEnd="@dimen/small_padding" androID:contentDescription="@string/abc_search_hint" androID:layout_alignParentStart="true" /> <TextVIEw androID:ID="@+ID/actionbarTitle" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/profile" androID:textSize="24sp" androID:textStyle="bold" androID:textcolor="@color/Black" androID:maxlines="1" androID:ellipsize="end" androID:contentDescription="@string/Title_activity_connect" androID:layout_centerInParent="true" /></relativeLayout>我已经尝试将TextVIEw对齐到ImageVIEw的右侧,但如果我这样做,它会停止在父级中心.任何帮助表示赞赏
解决方法:
你可以尝试这样的事情.为此,我使用了一个无线电组而不是线性布局,但它仍然可以工作.将线性布局水平放置,然后使布局重心,然后将图像放在文本视图之前
<RadioGroup androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:orIEntation="horizontal" androID:layout_gravity="center" androID:paddingtop="20dp"> <Radiobutton androID:ID="@+ID/radio_student" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/checkBox_student" androID:onClick="onRadiobuttonClicked" androID:layout_marginEnd="30dp" androID:layout_marginRight="30dp"/> <Radiobutton androID:ID="@+ID/radio_teacher" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/checkBox_teacher" androID:onClick="onRadiobuttonClicked" androID:layout_marginStart="30dp" androID:layout_marginleft="30dp"/> </RadioGroup>编辑:
我不知道按钮的边距属性是否可用于文本视图,但文本视图上的填充可能有效
以上是内存溢出为你收集整理的android – 相对布局,对齐父视图和右视图的中心,没有重叠全部内容,希望文章能够帮你解决android – 相对布局,对齐父视图和右视图的中心,没有重叠所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)