I'm building am app that will allow Odometer entry. I would like to use the image shown below as the background on an EditText. Doing that is no problem, however I can not seem to get the digits entered into the text view to line up in the spaces of the image. I've tried adjusted the text size, font face, etc.
Here is the image I would like to use...
Does anyone have any suggestions on how I can accomplish this? So that when the user entered digits into the EditText, each digit goes into the correct "slot"?
thank you!!!
You can use android:letterSpacing? (only applies api 21 and over)
Set up 6 separate EditTexts on top of that image each with dimensions of the square they need to go into. Then set up event handlers so that it appears to be one fluid motion across EditTexts when the user enters data. Not very elegant but it'll work.
Related
This is a simple Android question that is hard to explain.
For an EditText field, I need 18 characters.
I limited the lenght of the edittext now with android:maxLength="18"
What I really need to do is show a dot for each character, or something like a placeholder for each character. I know you can use a real placeholder in Android, but it disappears when you start to enter your text.
Do you guys know any library or other solution for this?
UPDATE: I rather not use 18 seperate edittexts. That would be a lot of hassle to use a textwatcher on each EditText etc..
After trying out your suggestions, I found a solution of my own.
I placed two editTexts on top of each other, set the text of the top editText to 18 dots(.) and enabled to false (to get the greyish look).
I left the other editText untouched.
In code I set both the typeFaces to monospace, to each character would have the same size.
The output is an editText with a grey dot for every character, exactly what I wanted.
Thanks for the help guys, I appreciate it!
In my application I have an EditText (Actually it's an implementation of MultiAutoCompleteTextView, but I don't think that matters) in which the user can enter a formula to be calculated, although generally they will want to just enter an integer.
What I would really like is for the keyboard to open with the numeric keyboard showing, but allow them to change to text if they want.
As standard of course it shows the letters and allwos them to change to numbers, which is OK, but 90% of the time they will want the numbers.
I tried doing:
operandEditText.setInputType(InputType.TYPE_CLASS_NUMBER|
InputType.TYPE_NUMBER_FLAG_SIGNED|InputType.TYPE_CLASS_TEXT);
But the result was a numeric keypad with letters written on the number keys (like a phone keypad), and it didn't write letters anyway.
I'm also aware that I could add a button, spinner or something that changed the input mode of the widget, but the aim of this is to make the interface easier to use, and I'm not sure adding another control will achieve that.
Is there a way to make it do what I want?
i have an AutoCompleteTextView widget on the view. if it has input focus and I'm trying to change the text in there with:
txtField1.setText("test");
I'm getting suggestions list appears on the screen. How do I hide it? is it possible to update the text not showing suggestions?
I'll leave this here, in case someone needs it in the future, like I did.
yourAutoCompleteTextView.dismissDropDown();
will make the list with suggestions disappear from the screen.
I suggest some methods
1)If you want to make "test" like hint of autocomplete textView then do like this,
txtField1.setHint("test");
2)If you need to fill up the text view with "test" and also need to prevent the suggestion increase the threshold level for auto complete textview ,
txtField1.setThreshold(5);
if you use threshold it will show suggestion after 5 character (according to the code posted in above line). If you need try to set different word and also try to avoid suggestion , change the threshold dynamically based on length of string.
I am looking to create an application that allows the user of the app the ability to create their own text box. It would be on top of an image file that I currently load. Basically they would zoom in to a place on the image, then drag with their fingers the position of the needed text box, then the box would be able to accept text...
I cannot find anywhere how I would accomplish this task ??? any suggestions or help would be much appreciated!!!
thank you!!
I am assuming based on
"then the box would be able to accept text..."
that you mean the user will be able to type things in to it.
If that is correct then an EditText is what you are looking for. By default this View is not set up to let the user
"drag with their fingers the position of the needed text box"
In order to make that work you'd have to write your own OnTouchListener for this view that recognizes the finger motions and changes the size of the EditText accordingly.
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.