相关疑难解决方法(0)

EditText在text属性下面加下划线

我想改变编辑文本下面的蓝色,我不知道它是什么属性.

我尝试使用不同的背景颜色,但它不起作用.

我在下面附上了一张图片:

在此输入图像描述

android login android-edittext

103
推荐指数
9
解决办法
15万
查看次数

为所有EditText设置一致的样式(例如)

我试图让EditText我的应用程序中的所有内容都具有一致的外观.我知道我可以这样做:

<style name="App_EditTextStyle">
    <item name="android:background">@drawable/filled_roundededges_box_dark</item>
    <item name="android:textColor">#808080</item>
    <item name="android:layout_height">45dip</item>
</style>
Run Code Online (Sandbox Code Playgroud)

然后我可以EditText通过这样做来制作一个特殊的风格:

<EditText ...
    style="@style/App_EditTextStyle
    ...>
Run Code Online (Sandbox Code Playgroud)

但是这样我必须记住为EditText我的应用程序中的每一个单独设置样式,这很繁琐,如果不是容易出错的话.

有什么办法可以让它成为主题的一部分吗?这样我就不必将这种风格与每种风格联系起来了EditText.像这个虚构的代码块:

<style name="App_Theme" parent="@android:style/Theme.Holo">
   ... 
   <item name="android:EditTextSyle">@style/App_EditTextStyle</item>
   ...
<style>
Run Code Online (Sandbox Code Playgroud)

然后在我的AndroidManifest.xml我有类似的东西:

<application
    ....
    android:theme="@style/App_Theme">
Run Code Online (Sandbox Code Playgroud)

还有瞧!所有我EditText都有一致的风格,而不必为每个实例指定样式.

android

78
推荐指数
3
解决办法
7万
查看次数

EditText光标和指针颜色为android 5.0以下

我试图更改EditText光标指针颜色(从原色蓝色到白色),但没有解决方案适用于我的项目.我试图开发演示项目,其中相同的代码工作正常.这段代码适用于> = android 5.0

我不知道,我的值会覆盖哪个属性.我有两个选项可以解决这个问题: -
1.找到控制该颜色值的属性.
2.页面加载时(在onViewCreated中)通过java代码更改颜色值.

请建议如何解决此问题.

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="my_text_layout_style">

        <item name="android:textColor">#FFF</item>
        <item name="android:textColorHint">#FFF</item>

        <item name="colorAccent">#FFF</item>
        <item name="colorControlNormal">#FFF</item>
        <item name="colorControlActivated">#FFF</item>

        <item name="colorControlHighlight">#FFF</item>

    </style>



    <style name="my_edit_text_style">
        <item name="colorAccent">#FFF</item>
        <item name="android:editTextStyle">@style/MyEditTextStyle</item>
    </style>

    <style name="MyEditTextStyle" parent="Widget.AppCompat.EditText" />
</resources>
Run Code Online (Sandbox Code Playgroud)

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@color/base_disable_btn_bg_color"
    android:orientation="vertical">

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:hint="just a hint"
        app:hintTextAppearance="@style/my_text_layout_style"
        android:theme="@style/my_text_layout_style"
        android:layout_height="wrap_content">

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:theme="@style/my_edit_text_style"
            android:layout_height="wrap_content" />

    </android.support.design.widget.TextInputLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

试图以编程方式添加视图但没有成功

AppLinearLayout appLinearLayout = (AppLinearLayout) view.findViewById(R.id.some_id);
EditText editText = new EditText(new ContextThemeWrapper(getContext(), …
Run Code Online (Sandbox Code Playgroud)

android android-edittext android-textinputedittext

10
推荐指数
1
解决办法
1566
查看次数