make autocompletetextview look like edittext - android

I am using an AutoCompleteTextView (RobotoAutoCompleteTextView) instead of an EditText. But I want the look and feel of an EditText: i.e. the underline that shows up at the bottom of an EditText. So how might I do that?
My question is a bit incomplete so let me clarify. In the Eclipse Graphical Layout the AutoCompleteTextView looks exactly like the EditText with the underline. But when I run the app in my Samsung Galaxy S5, the underline is gone. Instead I get an ugly box with some "#22000000" background. (Of course I am guessing at the exact hex of the background). So what I need is for the underline to always shows up no matter what device I am using: real phone, or just the Graphical Layout.

Try this:
<AutoCompleteTextView
...
style="#style/Base.Widget.AppCompat.EditText" />
or this
<EditText
...
style="#style/Base.Widget.AppCompat.AutoCompleteTextView"/>

Related

Difference between <android.support.design.widget.TextInputEditText> and <EditText>

I downloaded a code and the source is written in this format:
<android.support.design.widget.TextInputEditText/>
instead of:
<EditText/>
I tested both of them and i didn't see the difference, so I want to know if there's a difference between these two ways of declaring a widget in Android.
<android.support.design.widget.TextInputEditText/>
Creates a Field with an EditText with more functions like show the placeholder up the edit text when you're typing in.
https://gyazo.com/844d6c0fe8aace1ef671859823d39a58
https://gyazo.com/bf891de7807955e76bf487e3a07a6317
Only difference is: in landscape mode you can see the hint in TextInputEditText1, whereas you can't see in EditText.

Change Android EditText background color

I am developing an Android app. There's this issue with the EditTexts, because in some devices the "background" is white (which is the way I want it), but on others is transparent, and makes the app less professional. Here's an image with the "white background":
On other devices the edit texts that say "Yo" and "Casa" are transparent, so the words mix with the map and its pretty awful. I have tried changing the background color in the android layout xml. The closest one was I believe #drawable/white, but slightly changes the position and size of the edit text, making them look like they're one and its even worst.
Here is an example:
Is there a nice way to approach this problem? I read somewhere that an option was to add a white background image to the edit texts, but seemed like a lot of trouble.
UPDATE
I tried adding a background image, but its the same as changing the background color to any color using the android:background, the edit texts get like smaller or something. I added a blue "delimiter" to the image and this is the result:
But I want them like in the first picture, not so close one to another.
This would be the code of the edittext layout XML, the other one looks very similar. Only by adding the android:background tag changes from picture 1, to picture 3
SOLUTION
To solve this what I did was set a background image and set its height in dp as follows:
<EditText
android:id="#+id/markerTitle"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/buttonModifymarker"
android:ems="10"
android:inputType="textPersonName"
android:text="Título"
android:background="#drawable/editwhite"
>
Why don't you try setting the background of EditText programmatically?
yourEditText.setBackgroundColor(Color.WHITE);
or...
yourEditText.setBackgroundColor(Color.parseColor("#ffffff"));
simply you can add android:background="#drawable/white" attribute to your element in layout xml. you can use a lot of color resource between the double quotes (like from android color resources).
put the following image which has a solid white background in the drawable folder (it may dont appear because it's white and this page's background is white also) right click under this paragraph and select "Save Image as".
and refer to it in your layout and you will get a result like the following image
if the issue continue after trying this, please show me your layout code or email me at : mohamed_hamed4158#yahoo.com , thanks for voting my answer :)

Not able to enter values in EditText

I'm a newbie in Android development. Recently I have been facing a problem in the EditTexts(eventhough I havent changed any attributes of EditText) used in my app which I'm currently running in Emulator.
On clicking the EditText it receives focus, but on typing something the focus changes to some other view. But I'm able to enter values if I navigate to EditText using Tab button of the keyboard. This happens to all EditTexts in my application.
Surfed net for getting a solution, but did not find one.Help...
Implementation of one of my EditText:
<EditText
android:id="#+id/edittext_testname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/hintEditText1"/>
Thanks in advance.
Ever tried your app on a physical device?
However, I cannot see anything wrong with your EditText xml. Perhaps there is some java code in your activity catching any events related to that EditText? Or maybe to the other view element you mentioned getting the focus?
I had a similar issue but with a custom style I had defined for my EditText. How I fixed it?
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
So try applying the "android:focusable" and "android:focusableInTouchMode" properties and see if it makes any difference. They should be applied to the EditText by default but give it a go.
(I would have posted this as a comment but I need more rep)

Android TextView won't show right number of lines in Android 2.3

I have a couple of TextViews in my app, which should have exactly 3 lines. This works on Android 3+, but on Android 2.3, which I'd also like to support, these fields have exactly 2 lines. I've also tried TextView.setLines(3); in code, but that does not seem to help. This is my TextView:
<TextView
d1p1:lines="3"
d1p1:maxLines="3"
d1p1:minLines="3"
d1p1:ellipsize="end"
d1p1:text="Some Text"
d1p1:textAppearance="?android:attr/textAppearanceMedium"
d1p1:layout_width="fill_parent"
d1p1:layout_height="55dp"
d1p1:id="#+id/detailsTextView"
d1p1:layout_below="#+id/locationTextView"
d1p1:textSize="13dp"
d1p1:textColor="#color/app_darkgray"
d1p1:background="#color/app_dark_background"
d1p1:layout_marginLeft="#dimen/sr_horizontal_padding"
d1p1:layout_marginRight="#dimen/sr_horizontal_padding" />
Setting the height to wrap_content also does not work.
After some research it looks like my suspicion is correct. As discussed here (ellipsize multiline textview), Ellipsize causes issues with the min/max lines attributes. Because of this you may want to consider avoiding the Ellipsize otherwise, if that is not an option, you can follow the instructions in the other thread to use a custom TextView class to work around the problem.

Custom Position of Hint in Edit Text box.

I was wondering if there was any way that I could get a hint at the bottom of an Edit Text view -- and then the user to start entering text at the top of the box.
As a bonus question, is there any way I can make the hint NOT disappear once the user starts entering text.
You can set the position of the text using the "gravity" attribute (as noted at http://developer.android.com/reference/android/widget/TextView.html#setGravity(int)). So to put the text at the bottom you would have;
android:gravity="bottom"
And to answer your bonus question; No, you can't display the hint when text is entered into the edit text view. Displaying the hint only when the box is empty is the defined behaviour as noted at http://developer.android.com/reference/android/widget/TextView.html#setHint(int)
(and yes, I know the links are for TextView, but EditText derives all of its' text positioning and hint handling functionality from TextView).
Actually THERE IS a way to prevent hint from hiding, and it's a cool one :-)
It gives you the Floating Label look with smooth animation very easily and it's from android itself. No extra libraries and stuff.
Try this:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Touch me and I'll fly!"/>
</android.support.design.widget.TextInputLayout>
You can change the behaviour using other xml tags like android:gravity="start|center|end" and others.
As a BONUS, you can use error messages with it :-) Here's the link to that question: https://stackoverflow.com/a/30953551/6474744
And sorry I do not have enough reputatuion to post images, so help yourself:
http://i0.wp.com/androidlift.info/wp-content/uploads/2015/09/Screenshot_2015-09-28-17-03-561.png
Enjoy :-)
The problem with using both android:gravity and android:hint is that they are inter-linked with regard to cursor position.When you position the hint using gravity and you start entering text, it is entered in the same position as the your hint which is a problem if you want it to start traditionally on the top-left corner.

Categories

Resources