Splitted EditText for every character in Android - android

I need to create custom EditText so it will look like this:
I need it to be single EditText. Is it possible to do it, or do I need to create EditText for every character?

Yes it is possible! create multiple edit text's depending on the number of characters you want to accept as input and make sure to limit the size of each edit text to 1
android:maxLength="1"
You can set the width of each edit text and place them horizontally one after the other

You can create custom EditText by extending it. And you have to implement addTextChangeListener and their you can draw whatever you want. But No need to re Invent the wheel
And you can also use some build in customView like
PinView
Another
Also have a look at this

Related

How to create a custom view for EditText?

I need to have an EditText where the user will enter a password.
The problem is that it has to look a certain way:
What I did is - I used EditText for each separate digit, however I don't think this is the right solution. Is there a way I can use only one EditText and make it look like that? Is there any other approach I can use?

Use android:EditText as label

I want to set some text in EditText type fields. I want to do this while loading the activity. And then I don't want user to make any changes to it. Can I set EditText type boxes to non-editable mode? Does there exists any other element which could solve my purpose?
A TextView sounds like what you want; you can call setText() on them.
For EditText itself you could call this version of setText(), and set the buffer type to NORMAL instead of EDITABLE.
there are two options.
setEditable and setEnable. set false in Oncreate.
but in setEditable user can edit text by long click -> paste option.
If you are not taking any input from user in the EditText and it is just used to show some text that is set programmatically at onCreate, then you can use TextView instead. It is more suited for your requirement.
Here is a comparison between EditText and TextView that might be helpful.
Is there any particular reason for you to use a non-editable EditText? In case you absolutely have to use EditText then setting it as non-editable in your code after you set the value will suffice. You can do it in a few different ways, one of them would be setting input type as null in code.
yourEditText.setInputType(InputType.TYPE_NULL);
You can do android:enabled="false" in layout of that activity.
or
editText.setEnabled(false);

EditText Android and inner information

I need to achieve the similar behavior from the image below. I need to add extra static information inside an EditText in android that does not change according to the user's input (except for the character count).
How do I achieve this? As per I see from the focus, the data is inside the EditText and not out, so i believe this is some sort of style or a custom component.
Many Thanks
T
What you could do is make a view group with the text how you want it with an EditText at the top for the user input, then set the background of your view group to android:background="#android:drawable/editbox_background"
use setText() method of EditText with the appropriate BufferType
for the top text, and setHint() for the bottom one.

Is there any way to fix the amount of characters per line in an EditText without doing it programatically?

I just want to set the maximum amount of characters per line, so that the words will wrap onto the next line. Is there any way to do this? I looked over the EditText documentation and I don't see a clear way of doing this.
Any help is appreciated
You can set
android:maxWidth="200dip"
Inside your xml file for the EditText. This will make it wrap the text on to the next line once the width is reached. You'll have to play with the dip value to see how big you want it. As far as I know there is no way to measure this in characters though. You'll need to have the layout_height set to "wrap_content" also if you want the view to grow to show the text as it gets typed, if its longer than your view.
you can set maxlength property of edittext in our xml.

iphone-style text edit on android

I'm trying to make iPhone-style EditText element on android.
The one that will have an additional clear button appear on the right after text input.
Adding a new button is not a problem, but I'm a bit stuck with another thing.
A button occupies some space on the right part of EditText, and now characters display beneath the button. How to change maximum shown length of input for EditText?
I want EditText width to be N pixels, and editable area to be N-M pixels.
EditText.setWidth changes width for whole edit box.
EditText.setEllipsize should be the proper solution, but docs are empty, and as I see it truncates text based on some String value.
Applying a LengthFilter cut's the input length to number of characters.
Thanks in advance.
I suspect that android:drawableRight will save you a lot of pain.
Seems I've found a solution.
EditText.setPadding(l,t,r,b) seems to work fine, applying only for editable area
Try this : http://mytechead.wordpress.com/2012/02/07/create-ios-like-cleartextbutton-in-android/
This is a very old question, but thought I'd add my two cents for kicks. I'd probably use a 9 patch for this and set the content area to stop the text before it hits the button area.
This would require creating a custom view so that you can add a button in the desired position using relative layout so that it can be clicked to clear the edittext.
Alternatively you can use the compound drawables, but you would need to implement something like this
Handling click events on a drawable within an EditText so that you can handle the click events. Keep in mind that I doubt the button states (eg the down state) will work using this method.

Categories

Resources