简体   繁体   中英

Android EditText underline style not showing up in Emulator

Picture showing what I mean:

Emulator 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).

The problem is that the XML updates the style for the EditText underline, but it does not show it up on the Emulator. 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.

The background image has an elevation of -20dp, the black line is visible in the Emulator. 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.

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.

Read it from below link https://developer.android.com/reference/android/text/style/UnderlineSpan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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