在Android中对齐两个文本视图的基线 [英] Aligning baseline of two text views in Android
本文介绍了在Android中对齐两个文本视图的基线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请在我的布局和下方找到其结果;我需要文本"文本消息"与文本"标题"的基线对齐(请在代码和快照下方找到).有人可以给我指示会很高兴
please find below my layout & its result ; I need the text 'Text message' to align on the baseline of the text 'Header'(Please find below the code and snapshot). Would be glad if someone can give me direction
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1.0"
android:baselineAligned="true"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:background="@color/custom_orange"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Header"
android:textSize="25sp"
android:id="@+id/title"
android:gravity="center"
android:background="@color/custom_red"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Text message"
android:textSize="10sp"
android:id="@+id/language"
android:gravity="center"
android:background="@color/custom_green"/>
</LinearLayout>
</LinearLayout>
这是结果
这就是我需要的
推荐答案
将RelativeLayout用作TextViews的容器并添加属性
Use RelativeLayout as a container for TextViews and add the attribute
android:layout_alignBaseline="@+id/title"
到 id/语言 TextView
to id/language TextView
这篇关于在Android中对齐两个文本视图的基线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文