欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android EditText設置邊框的操作方法

 更新時間:2023年12月19日 11:07:38   作者:tracydragonlxy  
這篇文章主要介紹了Android EditText設置邊框,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

Android EditText設置邊框

簡介

Android應用程序中給EditText設置邊框。

效果圖:

快速開始

1.在res/drawable目錄下新建樣式文件 edit_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape
            android:shape="rectangle">
            <solid android:color="#efefef"/>
            <corners android:radius="5dp"/>
            <stroke
                android:width="1dp"
                android:color="#505050"/>
        </shape>
    </item>

2.布局文件中使用邊框效果,/res/layout/activity_edit_text.xml。

android:background=“@drawable/edit_background”

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".EditTextActivity">
    <TextView
        android:id="@+id/name_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="賬號:"
        android:textSize="18sp"
        android:textColor="#353535"
        android:layout_marginTop="60dp"
        android:layout_marginStart="60dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"/>
    <EditText
        android:id="@+id/edit_name"
        android:layout_width="200dp"
        android:layout_height="40dp"
        android:hint="請輸入賬號"
        android:gravity="center"
        android:inputType="number"
        android:background="@drawable/edit_background"
        android:layout_marginStart="10dp"
        app:layout_constraintTop_toTopOf="@id/name_label"
        app:layout_constraintBottom_toBottomOf="@id/name_label"
        app:layout_constraintLeft_toRightOf="@id/name_label"/>
    <TextView
        android:id="@+id/pwd_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密碼:"
        android:textSize="18sp"
        android:textColor="#353535"
        android:layout_marginTop="40dp"
        android:layout_marginStart="60dp"
        app:layout_constraintTop_toBottomOf="@id/name_label"
        app:layout_constraintLeft_toLeftOf="parent"/>
    <EditText
        android:id="@+id/edit_pwd"
        android:layout_width="200dp"
        android:layout_height="40dp"
        android:hint="請輸入密碼"
        android:gravity="center"
        android:inputType="textPassword"
        android:background="@drawable/edit_background"
        android:layout_marginStart="10dp"
        app:layout_constraintTop_toTopOf="@id/pwd_label"
        app:layout_constraintBottom_toBottomOf="@id/pwd_label"
        app:layout_constraintLeft_toRightOf="@id/pwd_label"/>
    <Button
        android:id="@+id/btn_login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ok"
        android:layout_marginTop="30dp"
        android:layout_marginStart="110dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@id/pwd_label"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Cancel"
        android:layout_marginStart="50dp"
        app:layout_constraintTop_toTopOf="@id/btn_login"
        app:layout_constraintLeft_toRightOf="@id/btn_login"/>
</android.support.constraint.ConstraintLayout>

到此這篇關于Android EditText設置邊框的文章就介紹到這了,更多相關Android EditText邊框內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Flutter 枚舉值enum和int互相轉(zhuǎn)化總結

    Flutter 枚舉值enum和int互相轉(zhuǎn)化總結

    這篇文章主要為大家介紹了Flutter 枚舉值enum和int互相轉(zhuǎn)化總結分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-02-02
  • Android實現(xiàn)購物商城

    Android實現(xiàn)購物商城

    這篇文章主要為大家詳細介紹了Android實現(xiàn)購物商城,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-04-04
  • Android仿淘寶詳情頁面viewPager滑動到最后一張圖片跳轉(zhuǎn)的功能

    Android仿淘寶詳情頁面viewPager滑動到最后一張圖片跳轉(zhuǎn)的功能

    需要做一個仿淘寶客戶端ViewPager滑動到最后一頁,再拖動的時候跳到詳情的功能,剛開始我也迷糊了,通過查閱相關資料發(fā)現(xiàn)有好多種實現(xiàn)方法,下面小編給大家分享實例代碼,感興趣的朋友一起看看吧
    2017-03-03
  • Android中應用前后臺切換監(jiān)聽的實現(xiàn)詳解

    Android中應用前后臺切換監(jiān)聽的實現(xiàn)詳解

    這篇文章主要給大家介紹了關于Android中應用前后臺切換監(jiān)聽實現(xiàn)的相關資料,文中通過示例代碼介紹的非常詳細,對大家具有一定的參考學習價值,需要的朋友們下面跟著小編來一起學習學習吧。
    2017-07-07
  • 詳解Android安全防護之加密算法

    詳解Android安全防護之加密算法

    Android應用對安全防范這方面要求越來越高了。特別是金融行業(yè),如果app沒有沒有做好安全處理,那些很容易被一些Hacker(黑客)所攻擊。并不是說做了這些安全防范,這個應用就百分之百的安全的。只是說能夠盡可能加大破解難度。本文將詳細介紹Android安全防護之加密算法。
    2021-06-06
  • Android給通知channel靜音的方法實例

    Android給通知channel靜音的方法實例

    這篇文章主要給大家介紹了關于Android如何給通知channel靜音的相關資料,文中通過實例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2022-02-02
  • Android App使用RecyclerView實現(xiàn)上拉和下拉刷新的方法

    Android App使用RecyclerView實現(xiàn)上拉和下拉刷新的方法

    RecyclerView一經(jīng)推出便被認為是替代ListView的存在,那么ListView的上拉和下拉刷新我們同樣可以使用RecyclerView來做到,這里我們就來看一下Android App使用RecyclerView實現(xiàn)上拉和下拉刷新的方法,首先先來點RecyclerView的小介紹:
    2016-06-06
  • ubuntu下 AndroidStudio4.1啟動報錯問題的解決

    ubuntu下 AndroidStudio4.1啟動報錯問題的解決

    這篇文章主要介紹了ubuntu下 AndroidStudio4.1啟動報錯問題的解決,本文給大家分享個人經(jīng)驗對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-10-10
  • 基于DownloadManager的簡單下載器編寫小結

    基于DownloadManager的簡單下載器編寫小結

    Android自帶的DownloadManager是一個很好的下載文件的工具。該類在API level 9之后出現(xiàn),它已經(jīng)幫我們處理了下載失敗、重新下載等功能,整個下載過程全部交給系統(tǒng)負責,不需要我們過多的處理,非常的nice。關鍵的是用起來也很簡單,稍微封裝一下就可以幾句話搞定下載
    2017-12-12
  • Android實現(xiàn)讀寫USB串口數(shù)據(jù)

    Android實現(xiàn)讀寫USB串口數(shù)據(jù)

    這篇文章主要為大家詳細介紹了Android實現(xiàn)讀寫USB串口數(shù)據(jù),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-09-09

最新評論