gpt4 book ai didi

android - 如何在 Android Studio 中为文本添加下划线?

转载 作者:太空宇宙 更新时间:2023-11-03 12:31:27 26 4
gpt4 key购买 nike

到处找,找不到解决办法。设置粗体或斜体很容易,为什么设置下划线就没那么容易了?

这是我的一些相关代码:

   <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/forgotpasswordHolder"
android:layout_marginTop="10dp">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Forgot your password?"
android:id="@+id/labForgotpassword"
android:textColor="#6BB08C"
android:layout_weight="1"
android:textStyle="bold|italic"
android:layout_gravity="left"
android:paddingLeft="20dp"
android:textIsSelectable="true"
android:singleLine="false" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Not a member?"
android:id="@+id/signup"
android:textColor="#6BB08C"
android:layout_weight="1"
android:textStyle="bold|italic"
android:singleLine="false"
android:layout_gravity="right"
android:gravity="right"
android:paddingRight="20dp"
android:textIsSelectable="true" />
</LinearLayout>

我有两个“忘记密码?”和“不是成员(member)?”按钮,如果我能在文本下划线,我会很高兴。

提前致谢!

最佳答案

使用 <u> 的字符串资源标签,像这样

android:text="@string/forgotPassword"

然后在strings.xml中,创建一个String

<string name="forgotPassword"><u>Forgot your password?</u></string>

关于android - 如何在 Android Studio 中为文本添加下划线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32787545/

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