如何在没有像孩子一样的TextInputEditText的情况下使用TextInputLayout?

时间:2018-10-04 14:44:23

标签: android android-textinputlayout android-textinputedittext

我想要一个相同的字段,例如Google Fit:

enter image description here

所以我添加了类似的TextInputLayout,但是我无法为隐藏光标,隐藏键盘设置editext:

<android.support.design.widget.TextInputLayout
            android:layout_width="0dp"
            android:layout_weight="0.6"
            android:layout_height="wrap_content"
            style="@style/TextInputLayoutStyle">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/date"
                style="@style/NewWizardItemPlanTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="none"
                android:hint="@string/date" />

        </android.support.design.widget.TextInputLayout>

非常感谢您的支持人员!

1 个答案:

答案 0 :(得分:0)

添加自定义视图并根据需要进行调整。!

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="150dp"
    android:layout_height="50dp"
    android:layout_margin="8dp"
    android:gravity="center_vertical"
    android:background="@drawable/border_btn">

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </Spinner>

</LinearLayout>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Date"
    android:textStyle="bold"
    android:paddingLeft="5dp"
    android:paddingStart="5dp"
    android:paddingRight="5dp"
    android:paddingEnd="5dp"
    android:textColor="#4e8cff"
    android:background="@color/white"
    android:layout_marginLeft="20dp"
    android:layout_marginStart="20dp"
    android:layout_marginTop="2dp"
    />

border_btn.xml

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

<solid android:color="#00000000" />

<stroke
    android:width="3dp"
    android:color="#4e8cff" />

<corners android:radius="5dp" />

</shape>

输出

enter image description here