How do you underline a text in an XML file? I can't find an option in textStyle
.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
First of all go to String.xml file
you can add any html attributes like , italic or bold or underline here.
If you are using a string resource xml file (supports HTML tags), it can be done using
<b> </b>
,<i> </i>
and<u> </u>
.If you want to underline something from code use:
Hope this helps
I used below method, it's work for me. below is example for Button but we can use in TextView as well.
If it does not work then
Because "<" could be a keyword at some time.
And for Displaying
Another way to do it, is creating a custom component extending TextView. It's good for cases where you need to have multiple underlined TextViews.
Here's the code for the component:
And how to use it in xml:
There are different ways to achieve underlined text in an Android TextView.
1.
<u>This is my underlined text</u>
or2.You can do the same programmatically.
3.It can be done by creating a SpannableString and then setting it as the TextView text property