【问题标题】:How to use TextInputLayout without a TextInputEditText like child?如何在没有像孩子一样的 TextInputEditText 的情况下使用 TextInputLayout?
【发布时间】:2018-10-04 14:44:22
【问题描述】:

我想拥有相同的字段,例如 Google Fit:

所以我添加了一个这样的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>

非常感谢大家的支持!

【问题讨论】:

  • 里面不是旋转器吗?
  • Google 可能会使用自定义视图来包装该微调器。

标签: android android-textinputlayout android-textinputedittext


【解决方案1】:

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

<?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>

输出

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多