java– 如何使用不同的字体大小居中两个textView

java– 如何使用不同的字体大小居中两个textView,第1张

概述<LinearLayoutandroid:id="@+id/layout_information"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="0.17"android:gravity="center"android:or

<linearLayout    androID:ID="@+ID/layout_information"    androID:layout_wIDth="0dp"    androID:layout_height="fill_parent"    androID:layout_weight="0.17"    androID:gravity="center"    androID:orIEntation="horizontal" >    <TextVIEw        androID:ID="@+ID/text_vIEw_destination"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="\@ Home in"        androID:textcolor="@color/solID_white"        androID:textSize="19sp"        androID:textStyle="bold"         androID:layout_gravity="bottom"        />    <TextVIEw        androID:ID="@+ID/text_vIEw_time"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_marginleft="30dp"        androID:textcolor="@color/solID_white"        androID:textSize="25sp"        androID:textStyle="normal"         androID:layout_gravity="bottom"        /></linearLayout> 

我想垂直居中两个textVIEws,

但我希望它们与底部的一条线对齐.

现在他们在同一个底部,

但它们位于父布局的底部.

我怎样才能做到这一点?

我曾想过用另一个布局包装他们当前的布局父(“parent1”)
( “parent2”)

并使“parent1”位于“parent2”的中心.

有没有添加元素的另一种方法?

解决方法:

如果您的问题是两个视图都在其父级的底部对齐,您可以使用它.
两个视图仍然对齐到同一个底部并以屏幕为中心.

您的布局看起来像是更大的XML(重量= 0.17)的一部分,这就是我在layout_wIDth上使用fill_parent的原因.

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:ID="@+ID/layout_information"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:layout_weight="0.17"androID:gravity="center"androID:orIEntation="horizontal" >    <TextVIEw    androID:ID="@+ID/text_vIEw_destination"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:text="\@ Home in"    androID:textcolor="@color/solID_white"    androID:textSize="19sp"    androID:textStyle="bold" />    <TextVIEw    androID:ID="@+ID/text_vIEw_time"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"            androID:layout_marginleft="30dp"    androID:text="\@ Home in"    androID:textcolor="@color/solID_white"    androID:textSize="25sp"    androID:textStyle="normal"    androID:layout_alignParentBottom="true"    androID:layout_toRightOf="@ID/text_vIEw_destination"    androID:layout_alignBaseline="@ID/text_vIEw_destination" /></relativeLayout>
总结

以上是内存溢出为你收集整理的java – 如何使用不同的字体大小居中两个textView全部内容,希望文章能够帮你解决java – 如何使用不同的字体大小居中两个textView所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1106909.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存