Sid
Sid

Reputation: 2862

Edit text bottom line looks black in android 4.1

I have put an edit text which has a tint color as white. But it looks black in android above 4.0 devices till lollipop.

I searched for this and got solutions as apply background color as white.

But I have another layout from which the edit text belongs which has dark blue color, so if I apply background color as white whole edit text looks white on that dark blue layout.

What can I do for this now?

Layout :

 <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>

color.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>

Please help, thank you..

EDIT:

I tried to add new theme and put it in activity in manifest, but did not help.

<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" />

Manifest :

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

Upvotes: 2

Views: 402

Answers (2)

Charuka Silva
Charuka Silva

Reputation: 13153

Create a drawable resource xml file (your requirement is only to have a bottom stroke)

Set givendrawable as the background of the editText then you can add the background color you need + bottom line you need with a color

Explain:

This is a resource drawable dashGap & dashWidth is for doted/broken lines (remove them if you do not need dashes)

android:top -> you can give minus sizes to the views that you don't need to display.(here your requirement is to show only bottom line so top,right & left lines of the item has given -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>

Upvotes: 2

user7315381
user7315381

Reputation:

you can set different different color accent at activity in your manifest file.

<color name="colorAccent">#FFFFFF</color>

Upvotes: 1

Related Questions