簡體   English   中英

為什么自定義繪圖未顯示在 android 中

[英]Why custom drawable not showing in android

TextView加屏

<TextView
        android:id="@+id/eventDetail_SpecialInfos"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="4dp"
        android:fontFamily="@font/source_sans_pro"
        android:text="Special Info"
        android:drawableBottom="@drawable/information_underline"
        android:textColor="@color/colorBlack"
        android:textSize="14dp" />

information_underline 可繪制是:

<stroke
    android:width="20dp"
    android:color="@color/colorBlack" />

檢查@Suaj 答案。
另一種方法是在材質組件庫中使用帶有 OutlinedBox 樣式的TextInputLayout

就像是:

<com.google.android.material.textfield.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    ..>

    <com.google.android.material.textfield.TextInputEditText
        ../>

</com.google.android.material.textfield.TextInputLayout>

在此處輸入圖像描述

您創建的 Drawable 不是正確的方法,請使用以下代碼在textview底部繪制任何內容

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <size
        android:height="1dp"
        android:width="100dp" />

    <solid android:color="@android:color/black" />

</shape>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM