Is there anyway to change the appearance of the EditText? - android

I want my edittext to be appeared as shown in pic1. My current edittext looks like pic2. Is there any way to change it through the edittext's properties? and why it is changing?
pic1
pic2

You can change the look of an EditText by changing the background image.
As has been pointed out, the reason it looks different is because of the android version. I don't recommend you use the old assets directly, but you could certainly make your own to look exactly how you want.

Related

android support lib 23.1.1 changes floating label color on setError()

is there a way to change the color of 'Password'? Basically, I prefer what support lib 23.1.0 had. I have a page that has multiple TextInputLayouts, and it would be hard to read if both hint and error are in red. please see the screenshot below.
there are a few fixes I want in 23.1.1, so please don't ask me to stay with 23.1.0. Thanks for all the help!!
Since it is a change in library it would be difficult to manipulate it. Android has decided to go that way (changing the label color along with the hint's color) and will become a standard soon and users will get familiar with it as time passes by. Not much we can do about it, but adhere, as always.
Workaround:
Don't set the Labels field on the TextInputLayouts. keep it blank and put another TextView just above it with the desired color and properly align it. That will not change, of course.
As per my comment below, you could also try this:
Hint color wont change. Just checked. So you may want to remove label and just add hint as android:hint="Enter password". The word Password in your screenshot is set in the Label and not as a hint.

Is it possible to insert/paste image on a custom EditText?

I wanted to create a custom text view. A little bit advance just as the text editor found here in StackOverflow, I can insert text and even images. I wanted to name this as WordView and create this as a library so I can reuse this across multiple projects.
Unfortunately I am not so sure if the base class allows this. I need a way to insert/paste images directly in the EditText. I am planning to write a custom View, although it seems laborious, I am not quite certain if this is possible at all and if I am going into the right track.
Have anyone tried similar before?
According to the Android Documentation for a TextView You can have a drawable object inside the TextView in the following ways
DrawableBottom
DrawableEnd
DrawableLeft
DrawableRight
DrawableStart
DrawableTop
There are other methods you can use, check out:
1. Programmatically set left drawable in a TextView
2. How to programmatically set drawableLeft on Android button?
3. http://androidsbs.blogspot.co.za/2013/12/androiddrawableleft-set-drawable-to.html
You could possibly implement this using HTML. I'm not sure about the paste functionality but generally it might work.

Android change TextField outline/boarder color

I have a text field, and on Android 2.2, when it is in focus or being used, it highlights it and puts an orange boarder around it.
The orange really doesn't look good with the other colors in my app, so I am wondering if there is any way to change that to a different color...
Thanks in advance.
You can write selectors for your textview using which you can change the appearance of your textview when it is selected.
You can refer to this:
http://developer.android.com/reference/android/content/res/ColorStateList.html

How to return to default style on EditText if I apply a background?

I just encountered with a problem that I don't know how to solve. It looks silly but I cannot find a way to fix it.
I have a form in android with several EditText and when you submit the form it checks those EditText and if they have wrong data I change the EditText to red border (applying a ninepatch image).
myEditText.setBackgroundResource(R.drawable.edittext_red);
The problem is, I want to restore android's default style when the user change the EditText, but I don't know how to do it. if I do:
myEditText.setBackgroundResource(0);
It will just remove everything and that's not what I want.
Thanks!
First, before you call setBackgroundResource with your own ninepatch, store the original background of the EditText, like this:
Drawable originalDrawable = myEditText.getBackground();
Then, if the user entered the wrong data, you can set your red border ninepatch:
myEditText.setBackgroundResource(R.drawable.edittext_red);
And later, when you want to restore the look of the EditText, use the stored drawable:
myEditText.setBackgroundDrawable(originalDrawable);
Alternatively you can reference the default Android EditText background directly like this:
myEditText.setBackgroundResource(android.R.drawable.edit_text);
At androiddrawables you can see how the different drawables look for the different versions of Android, and get their resource identifier. This method should work for all drawables, not just EditText
These (and other android resources) can also be found on your own system, in the android-sdk folder in
< path to android-sdk folder>/android-sdk/platforms/android-< API level>/data/res/
For material design with Kotlin:
edit.apply {
setBackgroundResource(androidx.appcompat.R.drawable.abc_edit_text_material)
}

changing EditText

When I change the layout_height of an EditText field in Android, the nice looking gradient becomes a hard gray line as you can see here:
Is there a way to either fix or disable this gradient?
thx
Ben
You may want to just give it a different background, using a nine-patch presumably. (I have noticed this too and don't like it either! :) )

Categories

Resources