gpt4 book ai didi

android - 如何使用样式在按钮内的文本下划线

转载 作者:行者123 更新时间:2023-12-05 00:13:46 26 4
gpt4 key购买 nike

<分区>

有没有一种方法可以使用样式为 Button 中的文本添加下划线?我可以通过用这样的 html 标记将文本包装在 strings.xml 中来实现

<string name="my_text"><u>My underlined text</u></string>

但我更喜欢这样

<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.TextButton"
android:id="@+id/my_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
<!-- not working --> android:textStyle="underline"
android:text="@string/my_text" />

理想情况下,我会在 styles.xml

中定义样式
<style name="MyButton" parent="Widget.MaterialComponents.Button.TextButton">
<!-- not working --><item name="android:textStyle">underline</item>
</style>

而且我知道我可能会制作我自己的自定义按钮,它会在文本上加下划线。但是,对于如此基本的东西,感觉就像需要付出很多努力。

编辑我的问题被标记为 this question 可能重复,但我正在尝试通过样式来实现下划线。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com