Android EditText textAllCaps不使用文本可选择

Android EditText textAllCaps不使用文本可选择,android,android-layout,Android,Android Layout,我的布局中有一个文本视图: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAllCaps="true" android:text="Hello" /> textAllCaps工作正常,没问题。但当我试图通过添加textIsSelectable使文本可选择时 <TextView and

我的布局中有一个文本视图:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAllCaps="true"
    android:text="Hello"
    />

textAllCaps工作正常,没问题。但当我试图通过添加textIsSelectable使文本可选择时

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAllCaps="true"
    android:textIsSelectable="true"
    android:text="Hello"
    />


textAllCaps不工作。这两个属性似乎不能正常工作。你有什么建议,为什么会发生这种情况,以及如何使文本都是大写和可选的(我感兴趣的是一个最清晰的方式,而不是设置文本更改侦听器和手动大写文本)。如果您有任何建议,我将不胜感激。

您能在
活动中尝试一下吗


edittext.setFilters(new InputFilter[]{new InputFilter.AllCaps()})

我找到了一个解决方案。使用AppCompatTextViewapp:textAllCaps

<android.support.v7.widget.AppCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:textAllCaps="true"
    android:textIsSelectable="true"
    android:text="Hello"
    />

告诉您仅在创建自定义组件时使用此组件),但它可以工作。

您可以将大写键盘的inputType属性设置为“textCapCharacters”作为默认值

<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapCharacters"
/>

像这样使用
像这样使用
`在这里输入代码`

设置焦点可调到触摸模式(true)&&
setFocusable(真)你可以使用@Logic answer,它对我有用。。。。
use like this

<android.support.design.widget.TextInputLayout
                            android:id="@+id/input_postcode"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"

                            android:inputType="textCapCharacters"  //use this line dont forgot
                            android:textColorHint="@color/white"
                            app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout">

                            <EditText
                                android:id="@+id/et_postcode"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="10dp"
                                android:backgroundTint="@color/white"
                                android:gravity="center_vertical"
                                android:hint="Post code "
                                android:inputType="text" //dont use hereinputtype
                                android:imeOptions="actionNext"
                                android:maxLength="4"
                                android:padding="10dp"
                                android:textAllCaps="true"
                                android:singleLine="true"
                                android:textColor="@color/white"
                                android:textColorHint="@color/white"
                                android:textSize="15sp" />
                        </android.support.design.widget.TextInputLayout>
use like this

<android.support.design.widget.TextInputLayout
                            android:id="@+id/input_postcode"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"

                            android:inputType="textCapCharacters"  //use this line dont forgot
                            android:textColorHint="@color/white"
                            app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout">

                            <EditText
                                android:id="@+id/et_postcode"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="10dp"
                                android:backgroundTint="@color/white"
                                android:gravity="center_vertical"
                                android:hint="Post code "
                                android:inputType="text" //dont use hereinputtype
                                android:imeOptions="actionNext"
                                android:maxLength="4"
                                android:padding="10dp"
                                android:textAllCaps="true"
                                android:singleLine="true"
                                android:textColor="@color/white"
                                android:textColorHint="@color/white"
                                android:textSize="15sp" />
                        </android.support.design.widget.TextInputLayout>`enter code here`