Why*_*ser 9 android android-4.3-jelly-bean android-4.4-kitkat
正如问题所说:在运行Android 4.3+的设备上测试应用程序(也在4.4上测试)时,提示的颜色(对于EditText)变为白色,无论我将其设置为什么颜色,它都保持白色.由于EditText的背景为白色,因此肉眼看不到提示!
我用谷歌搜索和谷歌搜索,找不到任何人有同样的问题.该应用程序是使用android:minSdkVersion="8"和构建的android:targetSdkVersion="15".EditText看起来像这样:
<EditText
android:id="@+id/editText3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/my_background"
android:ems="10"
android:textColorHint="@color/BlueViolet"
android:hint="@string/my_hint"
android:inputType="number"
android:tag="21_0" />
Run Code Online (Sandbox Code Playgroud)
起初它是使用默认值android:textColorHint,我认为可能Android 4.3+由于某种原因将默认值更改为白色.但事实并非如此,因为无论我设定的颜色是什么,它总是白色的.
我知道这fill_parent已被弃用,但该应用程序很久以前就已经构建,但由于提示消失而现在无法使用.任何帮助表示赞赏!谢谢!
编辑:使用字符串资源提示时似乎发生'错误'.这有效:android:hint="Hello world"虽然这不行android:hint="@string/my_hint"
Erh*_*SEN 18
谁在同样的问题上挣扎;
如果您使用了edittext
android.support.design.widget.TextInputLayout
Run Code Online (Sandbox Code Playgroud)
你应该把你的
android:textColorHint="@color/BlueViolet"
Run Code Online (Sandbox Code Playgroud)
在TextInputLayout中
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="@android:color/white">
<AutoCompleteTextView
android:id="@id/etextEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_card"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:textColor="@android:color/white"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
从 Android 4.3+ 开始,似乎不再可以按如下方式制作字符串资源(但不确定它是否本来就应该这样工作):
<string name="my_hint"><font size="13" fgcolor="#ffbbbbbb">Hello world</font></string>
Run Code Online (Sandbox Code Playgroud)
如果这样做,它们就会变成白色。因此,您必须以这种方式创建字符串资源:
<string name="my_hint">Hello world</string>
Run Code Online (Sandbox Code Playgroud)
然后使用 TextView/EditText 上的属性来编辑提示的颜色。要改变大小,似乎仍然可以这样做:
<string name="my_hint"><small><small>Hello world</small></small></string>
Run Code Online (Sandbox Code Playgroud)
我通过阅读这个答案的评论发现了这一点: https: //stackoverflow.com/a/11577658/2422321,作者:Edward Falk
| 归档时间: |
|
| 查看次数: |
4743 次 |
| 最近记录: |