gpt4 book ai didi

android - 如何将 TextInputLayout 用作按钮

转载 作者:行者123 更新时间:2023-11-30 00:27:05 24 4
gpt4 key购买 nike

我有一个像这样的 AppCompatEditText 的 TextInputLayout

<RelativeLayout
android:id="@+id/rv_from_date_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp">

<android.support.design.widget.TextInputLayout
android:id="@+id/edt_from_date_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:layout_toStartOf="@+id/iv_from_date_picker"
android:fontFamily="sans-serif-light"
android:textColor="@color/colorPrimary"
android:textColorHint="@color/colorPrimary"
android:theme="@style/TextLabelDark"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/colorPrimary">

<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_from_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="From Date"
android:maxLines="1"
android:textColor="@color/colorPrimary"
android:textColorHint="@color/colorPrimary"
android:textCursorDrawable="@null"
app:backgroundTint="@color/colorPrimary" />

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

<ImageView
android:id="@+id/iv_from_date_picker"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="8dp"
android:src="@drawable/date_range" />

</RelativeLayout>

ScreehShot

点击 AppCompatEditText 我需要显示一个日期选择器。但我不想弹出键盘。

我尝试了以下方法:

1. edt_from_date.setEnabled(false);
2. edt_from_date.setKeyListener(null);
3. rv_from_date_holder.setOnclickListener()//Also didn't worked

如果我禁用,我将无法弹出日期选择器。如果我将 KeyListener 设置为 null,那么我需要点击两次以获取日期选择器。

最佳答案

你应该添加

android:focusable="false"

<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_from_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="From Date"
android:maxLines="1"
android:focusable="false"
android:textColor="@color/colorPrimary"
android:textColorHint="@color/colorPrimary"
android:textCursorDrawable="@null"
app:backgroundTint="@color/colorPrimary" />

以及内部 Activity/fragment 集

onClickListener

关于android - 如何将 TextInputLayout 用作按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45144752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com