簡體   English   中英

我想要如圖所示的輪廓文本字段,未單擊edittext或微調器我想要與按鈕單擊上的視圖相同

[英]I want outlined text field with as shown in picture not clicked on edittext or spinner i want same as it is view on Button click

請讓我知道是否有人知道我得到文本但點擊edittext但我想要兩者都沒有任何點擊我想要相同的視圖,如下圖所示

在此處輸入圖像描述

      <com.google.android.material.textfield.TextInputLayout
        android:layout_below="@+id/spinnerTextInput"
        android:id="@+id/device_text"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Device Name"
        app:hintTextColor="@color/subText"
        app:boxStrokeColor="@color/colorBlack"
        app:boxStrokeWidthFocused="1dp"
        app:errorEnabled="true"
        android:layout_margin="10dp">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/device_name_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/shotOn"
            android:textColorHint="@color/subText"
            android:textColor="@color/TitleBlack">

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


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

設置 EditText 的 Padding

android:padding="20dp"

它被稱為 大綱文本字段 你可以克隆這個 repo material-components-android自己看在此處輸入圖像描述 這里是風格

<com.google.android.material.textfield.TextInputLayout
  style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_margin="4dp"
  android:hint="@string/cat_textfield_label"
  app:counterEnabled="true"
  app:counterMaxLength="10"
  app:errorEnabled="true"
  app:helperText="@string/cat_textfield_outlined_helper_text"
  app:helperTextEnabled="true"
  app:placeholderText="@string/cat_textfield_placeholder_text">
<com.google.android.material.textfield.TextInputEditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>

誰在給評論請檢查問題和答案然后給你意見謝謝你的回復。 在這里我提交我的問題的答案

        <RelativeLayout
        android:layout_below="@+id/spinnerTextInput"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="15dp"
            android:background="@drawable/boarder"
            android:paddingLeft="5dp"
            android:text="input" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="7dp"
            android:background="@color/white"
            android:textColor="@color/TitleBlack"
            android:text="Label" />
    </RelativeLayout>

在drawable中制作一個寄宿生xml並添加以下代碼

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

   <stroke
    android:width="2dp"
    android:color="@color/TitleBlack" />

    <corners android:radius="10dp" />
     </shape>

暫無
暫無

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

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