簡體   English   中英

如何制作這種類型的自定義EditText UI?

[英]How can I make this type of custom EditText UI?

我正在嘗試在編輯文本上加上邊框,並在上面加上標簽。 我已經試過了。 在此處輸入圖片說明

<stroke
    android:width="2dp"
    android:color="@color/colorPrimary"/>
<corners android:radius="15dp"/>

但我想要以下一個。 最初看起來像這樣。 在此處輸入圖片說明

單擊后將是這樣。 在此處輸入圖片說明

你能幫忙嗎?

使用材質設計的大綱框樣式=“ @ style / Widget.MaterialComponents.TextInputLayout.OutlinedBox”

此鏈接可能會幫助您http://qaru.site/questions/1688917/custom-textinputlayout-android

正如@ZahoorSaleem所說,您可以為此使用MaterialComponents。 您需要將設計支持庫添加到構建文件中。

布局將(簡化)如下所示:

<TextInputLayout       
  android:hint="Label"
  style="style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
    <TextInputEditText />
</TextInputLayout>
put the below code in drawable and use this attribute in edittext
 android:background="@drawable/nameofdrawablefile"
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="#CC0505"/>
    <stroke android:width="2dp" android:color="#CC0505" />
    <corners android:radius="5dp" />
</shape>

暫無
暫無

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

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