Can you hide the line in an EditText? For example, I am using an EditText for login and the background color is dark. I want to use an ImageView of a white line below an edit text and just have the edit text above the line. Please note I'd like the EditText to still have a hint, just not a line.
android:background="#null"
On your EditText, you could also use a color
Related
I have 2 EditText and a button. When I click the button I want to print a text in the editText which is selected.. How I can do this??
Try to use this:
Get Cursor Position in Android in Edit Text?
In your onClick ask for the myEditText.getSelectionStart(); if is not null thats your EditText.
I hope this helps.
UPDATE
It looks more complicated than i thought at first, you are looking for a focus state. See if any of this answers helps you.
How can I detect focused EditText in android?
Please tell me how to hide the text on a button in android.
When I try this code, the button is hidden but I just want to hide the text on the button.
Button b= (Button)findViewById(R.id.follow);
b.setVisibility(View.GONE);
Please tell me how to solve this.
Thank you.
I have a suggestion if you want to setText to a button but don't want to show it.
Just set the text in the xml
android:text="TEXT"
then make font to 0
android:textSize="0sp"
text exist but can't be seen.
On your button use mButton.setTextScaleX(0); so the text will be hidden and to show use mButton.setTextScaleX(1);
If you just want to hide the Text and not the Button b.setVisibility(View.GONE) will not work.
It will hide the button itself and also button will not occupy any space in your layout as you are using View.GONE.
Using b.setText("") should help you setting just an empty text on Button.
May be you need to call invalidate()to refresh the UI.
First take backup of existing text on your button then clear button text to hide text. And to show text again reuse backup text :
Button b = (Button)findViewById(R.id.follow);
//Backup button text
String mButtonText = b.getText();
//Now hide text
b.setText("");
//To show text again
b.setText(mButtonText);
You can set the button text to just be blank instead of trying to hide the button.
Button button = (Button)findViewByID(R.id.ButtonID);
button.setText(" ");
This will allow you to change the text of the button within your source, so you will be able to change the button text when an event happens or even just set the button text to blank when it is created.
Button.setTextColor(getResources().getColor(android.R.color.transparent));
This will make the text transparent/hidden. It will keep the original size of the button and keep the original text.
on your xml. remove the android:txt=" " on your button.
Try this
<Button
android:text="TEXT"
android:textColor="#00000000"/>
general info:
#<alpha><red><green><blue>
all in hexadecimal 00 to ff
I Want to make my EditText empty when you put a new value. If I use a onClickListener I need first to focus and then to click (Double click), if I use onFocusChangeListener it is already deleting when click another EditText.
Does someone know a other way to achieve this (When first click == empty)?
Thanks in advance!
Don't make things complicated. Simply set android:selectAllOnFocus="true" to your EditText. So, when the user types-in some text and later click the text box, all the text inside will be highlighted - allowing user to type-in new text from scratch.
Please provide the implementation of watermark text in EditText widget of android,even after Googling it, but cannot find proper solution!
If by "watermark text" you mean the text which appears in the field when it is empty, then use the attribute android:hint="My Text" in the layout or programmatically call setHint( "My Text" ) on your EditText object.
You can add a layout make its height and width fill_parent and make background transparent and add a TextView as a water-mark in this layout.
I hope it can work.
all,
We know on Andorid, for a EditText, by default, whenever the EditText is clicked, the soft keyboard pops up to let you enter text. When you click DONE, it closes out and put the text directly to the EditText.
Now, what I am trying to do is, instead of an EditText, I have an ImageView which is to let user enter some comment.(So the ImageView actually is an comment icon). I wish whenever the icon is clicked, it pops up the text editor with user previous entered text, again once the DONE is hit, it closes out and I can save whatever text there back to a string member of the Activity. Is that possible?
So far, all I've seen about InputMethodManager is on EditText control, If it is too complicated, I probably just put an EditText into a sperate Activity.
Thanks.
There are many solutions:
One is to use custom dialog: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Second one is to use a transparent activity on top of that one.
Then you could use FrameLayout and insert another view in an exact position...
I think you should try the frist or second one. Every ImageView can be easily converted into a button by adding onClick event to it.