【发布时间】:2015-11-09 12:40:50
【问题描述】:
【问题讨论】:
-
像这样设计一个图像文件并将其设置为textview的bottomdrawable
标签: android android-layout android-edittext android-styles
【问题讨论】:
标签: android android-layout android-edittext android-styles
你的问题是关于 Android 主题的东西。也许你应该设置你的主题的 colorControlNormal 值。就像下面这样:
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">#YOUR COLOR HEER</item>
</style>
参考here。
【讨论】:
试试这个,
editText.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
【讨论】:
您是否在使用 AppCompat 库?如果是,您可以覆盖样式属性colorControlNormal、colorControlActivated 和colorControlHighlight。
例如:
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">@color/your_color_1</item>
<item name="colorControlActivated">@color/your_color_2</item>
<item name="colorControlHighlight">@color/your_color_3</item>
</style>
【讨论】:
试试这个可能对你有帮助
<EditText
android:textColorHint="@android:color/white"
android:id="@+id/username"
style="@style/EditUnderBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:hint="@string/hint_email" />
在你的 style.xml 中添加这个
<style name="EditUnderBar" parent="android:Widget.Holo.Light.TextView">
<item name="android:drawableBottom">@drawable/under_bar</item>
<item name="android:drawablePadding">3dp</item>
<item name="android:layout_marginTop">12dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">16sp</item>
</style>
添加这个你的drawable
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="1000dp" android:height="1dp" />
<solid
android:color="@color/white"/>
</shape>
如果它不起作用,那么也添加它
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="colorControlNormal">@color/iron</item>
<item name="colorControlActivated">@color/white</item>
<item name="colorControlHighlight">@color/white</item>
<item name="android:textColorHint">@color/white</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowBackground">@color/white</item>
</style>
它对我有用
它可能对你有帮助。祝你好运
【讨论】:
在edittext中更改线条颜色的最简单方法是在您的xml文件中写入:
API >= 21:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="YOUR COLOR" />
API
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:backgroundTint="YOUR COLOR" />
【讨论】:
或者试试:
android:backgroundTint:”@color/colorWhite”
【讨论】: