如何将TextView容器内的文本对齐顶部?

时间:2018-12-20 09:03:51

标签: android textview

美好的一天。 将TextView内的文本水平对齐不是问题。但是,如何将TextView中的文本按在顶部呢?有必要将两个TextViews中的文本与顶部对齐,并且两个<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="60sp" android:gravity="top" android:text="TextView" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:text="TextView" app:layout_constraintStart_toEndOf="@+id/textView2" app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout> 内部应具有不同的文本大小。

{{1}}

here the image

添加: android:includeFontPadding =“ false”无法解决问题:

that's why

1 个答案:

答案 0 :(得分:3)

在您的文本视图中添加它:

android:includeFontPadding="false"
相关问题