What should I do to keep my Android screen full of characters?

Asked 2 years ago, Updated 2 years ago, 34 views

Regardless of the model, I would like to make the text length full of the screen, whether vertically or horizontally on my smartphone.What should I do?

This is a regular TextView.

Tried

<TextView
    android: id="@+id/main_text_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:layout_gravity="center"
    android:text="Start"
    android:autoSizeTextType="uniform"
    android: textColor="@color/colorBlack"/>

I want to fill up the middle of the screen and the full screen, but it appears small in the upper left corner.

android

2022-09-30 18:03

1 Answers

main_activity.xml:

<androidx.constraintlayout.widget.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:layout_width="0dp"
        android:layout_height="0dp"
        android:autoSizeMaxTextSize="300sp"
        android:autoSizeTextType="uniform"
        android:gravity="center_vertical"
        android:maxLines="1"
        android:text="Hello!"
        app:layout_constrainBottom_toBottomOf="parent"
        app:layout_constrainLeft_toLeftOf="parent"
        app:layout_constrainRight_toRightOf="parent"
        app:layout_constrainTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Preview Screenshot


2022-09-30 18:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.