AppCompatTextView内的文本超出范围

问题描述 投票:0回答:1

我有一个AppcompatTextView,其属性如下面的xml代码所示。事实是,此视图超出了图像中所示的范围。我该如何解决这个问题?

<androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/playertwo"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:gravity="center"
            android:letterSpacing="0.13"
            android:lines="1"
            android:padding="4dp"
            android:text="@string/player"
            android:textColor="?attr/main_color_reverse"
            app:autoSizeMaxTextSize="50sp"
            app:autoSizeMinTextSize="12sp"
            app:autoSizeStepGranularity="2sp"
            app:autoSizeTextType="uniform"
            app:fontFamily="@font/phenomena_bold" />

textview

如果需要任何其他信息,请告诉我

编辑

完整版块

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="?attr/background_color"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.1"
        android:orientation="horizontal"
        android:padding="@dimen/sides_margin"
        android:weightSum="18">

        <Space
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/playerone"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:layout_weight="4"
            android:gravity="center"
            android:letterSpacing="0.13"
            android:lines="1"
            android:padding="4dp"
            android:text="@string/player"
            android:textColor="?attr/main_color_reverse"
            app:autoSizeMaxTextSize="50sp"
            app:autoSizeMinTextSize="12sp"

            app:autoSizeStepGranularity="2sp"
            app:autoSizeTextType="uniform"

            app:fontFamily="@font/phenomena_bold" />

        <Space
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <ImageView
            android:id="@+id/player1sign"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:contentDescription="@string/x_desc"
            android:src="@drawable/x_underlined_dt">


        </ImageView>

        <Space
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2" />

        <ImageView
            android:id="@+id/player2sign"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:contentDescription="@string/o_desc"
            android:src="@drawable/o_underlined_dt">


        </ImageView>

        <Space
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/playertwo"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:gravity="center"
            android:letterSpacing="0.13"
            android:lines="1"
            android:padding="4dp"
            android:text="@string/player"
            android:textColor="?attr/main_color_reverse"
            app:autoSizeMaxTextSize="50sp"
            app:autoSizeMinTextSize="12sp"
            app:autoSizeStepGranularity="2sp"
            app:autoSizeTextType="uniform"
            app:fontFamily="@font/phenomena_bold" />

        <Space
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

    </LinearLayout>

</LinearLayout>
android
1个回答
0
投票

最简单的方法,更改layout_weight。但是从我的角度来看,最好使用ConstraintLayout +水平链,它会更灵活。

© www.soinside.com 2019 - 2024. All rights reserved.