gpt4 book ai didi

java - 编辑文本底线在 android 4.1 中看起来是黑色的

转载 作者:搜寻专家 更新时间:2023-11-01 08:30:40 25 4
gpt4 key购买 nike

我已经放置了一个颜色为白色的编辑文本。但它在 android 4.0 以上的设备上看起来是黑色的,直到 lollipop。

我搜索了这个并得到了将背景颜色应用为白色的解决方案。

但我有另一个布局,编辑文本属于深蓝色,所以如果我将背景颜色应用为白色,整个编辑文本在那个深蓝色布局上看起来是白色的。

我现在可以为此做什么?

布局:

 <RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/purple_bg"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:id="@+id/linearLayout"
android:weightSum="1">

<EditText
android:layout_width="match_parent"
android:layout_height="42dp"
android:id="@+id/editTextOrderItem"
android:layout_gravity="center_vertical"
android:backgroundTint="#ffffff"
android:drawableTint="#ffffff"
android:hint="Type here..."
android:textColorHint="#ffffff"
android:paddingLeft="15dp"
android:imeOptions="actionDone"
android:textSize="12sp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:layout_toLeftOf="@+id/imageViewSearch"
android:layout_toStartOf="@+id/imageViewSearch"
android:singleLine="true" />

<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/imageViewSearch"
android:backgroundTint="@android:color/white"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_gravity="center"
android:src="@drawable/btn_search"
android:layout_centerVertical="true"
android:padding="10dp"
android:layout_marginRight="06dp" />

</RelativeLayout>

颜色.xml

    <?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#eeeeee</color>
<color name="colorAccent">#3e3e3e</color>
<color name="black">#747474</color>
<color name="drawerBacground">#e6f7fd</color>
<color name="themetextcolor">#009688</color>
<color name="darktextcolor">#000000</color>
<color name="lighttextcolor">#ACABAC</color>
<color name="activity_bg_color">#D9E7E4</color>
<color name="activity_footer_color">#37b0a0</color>
<color name="btn_text">#b3ffffff</color>
<color name="seperator">#dedede</color>
<color name="accent">#00B0FF</color>
</resources>

请帮忙,谢谢..

编辑:

我尝试添加新主题并将其放入 list 中的 Activity 中,但没有帮助。

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/accent</item>
<item name="android:typeface">monospace</item>
<item name="android:textSize">17sp</item>
</style>
<style name="AppTheme2" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:typeface">monospace</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="AppTheme1" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:typeface">monospace</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/accent</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

list :

     <activity android:name=".Activities.MainActivity"
android:theme="@style/AppTheme2"
/>

最佳答案

创建一个drawable资源xml文件(你的要求只是有一个下划线)

将给定的drawable设置为editText的背景然后你可以添加你需要的背景颜色+你需要的底线颜色

解释:

这是一个资源drawabledashGap & dashWidth 用于点线/虚线(如果您不需要需要破折号,请将其移除)

android:top -> 您可以为您不需要views设置minus尺寸显示。(这里您的要求是仅显示底线,因此项目的顶部、右侧和左侧行已给出 -2dp )

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<shape android:shape="rectangle" >
<solid android:color="#FFF" /> <-- background color here
</shape>
</item>

<item android:top="-2dp" android:right="-2dp" android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:dashGap="10px"
android:dashWidth="10px"
android:width="1dp"
android:color="#ababb2" <-- bottom line color here />
</shape>
</item>

</layer-list>

关于java - 编辑文本底线在 android 4.1 中看起来是黑色的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41217429/

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