简体   繁体   English

Android EditText 下划线样式未显示在模拟器中

[英]Android EditText underline style not showing up in Emulator

Picture showing what I mean:图片显示了我的意思:

Emulator VS XML模拟器 VS XML

I'm using the standard template for Login Activity from Android Studio and trying to edit that, my minSDK is 21, targetSDK is 30 (Emulator is running on API 30).我正在使用 Android Studio 中登录活动的标准模板并尝试对其进行编辑,我的 minSDK 为 21,targetSDK 为 30(模拟器在 API 30 上运行)。

The problem is that the XML updates the style for the EditText underline, but it does not show it up on the Emulator.问题是 XML 更新了 EditText 下划线的样式,但它没有显示在模拟器上。 In the Emulator is the same black thin line.在模拟器中是同样的黑色细线。

I've tried a lot of solutions I've found on stackoverflow and also several links (like https://www.codexpedia.com/android/setting-edittext-underline-color-in-android/ ) but nothing works.我已经尝试了很多在 stackoverflow 上找到的解决方案以及几个链接(如https://www.codexpedia.com/android/setting-edittext-underline-color-in-android/ ),但没有任何效果。

The background image has an elevation of -20dp, the black line is visible in the Emulator.背景图像的高程为 -20dp,黑线在模拟器中可见。 Also, I've tried putting shapes over it as shown in the previous link or for example this code:此外,我尝试将形状放在上面的链接上,例如此代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="1dp"
        android:left="-3dp"
        android:right="-3dp"
        android:top="-3dp">
        <shape android:shape="rectangle">
            <stroke
                android:width="2dp"
                android:color="#fff" />

            <solid android:color="#00ffffff" />

        </shape>
    </item>
</layer-list>

But everything works just fine in the XML design panel, while the design is not applied in the Emulator.但是在 XML 设计面板中一切正常,而设计并未应用于模拟器。

Everything else shows up properly in the Emulator.其他一切都在模拟器中正确显示。 If I edit a string or something, it updates in the Emulator.如果我编辑字符串或其他内容,它会在模拟器中更新。

Can someone help me, please?有人能帮助我吗?

Please try with SpannableString to underline or colour or hyperlink etc.请尝试使用 SpannableString 下划线或颜色或超链接等。

Read it from below link https://developer.android.com/reference/android/text/style/UnderlineSpan从下面的链接https://developer.android.com/reference/android/text/style/UnderlineSpan阅读

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM