【问题标题】:Button text automatically change to capital letter in android [duplicate]按钮文本在android中自动更改为大写字母[重复]
【发布时间】:2016-11-17 08:16:54
【问题描述】:

我的 xml 布局中有一个按钮

         <Button
             android:layout_marginTop="10dp"
             android:layout_marginLeft="30dp"
             android:layout_marginRight="30dp"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"

            android:text="Default ringtone"
             android:id="@+id/select_ringtone"
                     />

当我在上面设置任何文本时,它会自动变为大写字母。即使我在 xml 或片段中设置。我不知道是什么问题!!!!我正在开发一个应用程序,但突然遇到了这个问题,这让我很困惑

【问题讨论】:

  • 您可能还需要考虑检查您正在使用的样式,因为它可能使用自然大写的字体。

标签: android button text uppercase


【解决方案1】:

我假设,您使用的是 23 API 级别。它的默认设置在那里。 别担心。

只需添加

android:textAllCaps="false"

【讨论】:

  • 非常感谢您节省了我的时间。但我不知道为什么会这样,因为我正在开发一个应用程序,突然我遇到了这个问题
【解决方案2】:

以编程方式更改按钮的转换方法。 btn.setTransformationMethod(null);

<style name="MyButton" parent="Widget.AppCompat.Button">
        <item name="android:textAllCaps">false</item>
    </style>

【讨论】:

    【解决方案3】:

    像这样使用 TextView

                <TextView
                 android:layout_marginTop="10dp"
                 android:layout_marginLeft="30dp"
                 android:layout_marginRight="30dp"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:text="Default ringtone"
                 android:id="@+id/select_ringtone"
                         />
    

    在这种情况下,您的文本以小写字母显示

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 2021-01-28
      • 1970-01-01
      • 2013-06-17
      • 2019-06-02
      • 2021-03-27
      • 2019-10-01
      • 2021-07-04
      • 2017-12-29
      相关资源
      最近更新 更多