My timer app (see picture below) seems like a EditText field where i can set numbers (from right to left). After setting one number it jumps to the one left to it (or if it is its end, it replaced the first number on the right). It also have leading zeros.
So i want to create something like this too, but not with a fixed amount of numbers. Is this possible with a editText or should i use TextView or another element? I tried to use EditText because on focussing it can open a Numpad (i don't want a fixed Numpad).
Related
I would love to add this elegant verification code screen to my app but I'm completely lost in how to do it
should I implement each box as a TextInputEditText ?
how can I make the cursor move from one box to the next one while typing ?
ps : I'm using kotlin
I would make those boxes as a TextViews (not EditText) - you don't want to have a soft keyboard opened and the user will be only using buttons below in order to enter verification code.
When the user presses number below - show it in the next available TextView, when every TextView is filled with number - verify whole code. The same should work backspace button - clearing previous filled TextView.
You might want to make TextView to be highlight when it is going to be filled with the next number press, you can do this with a state-list background.
is There any way in android to make some lines of the long text loose color ?
I'm giving you all the hints which you need to come up with solution rather than writing a solution
I'm assuming that your text is dynamic in nature that means text length will vary.
First of all, you will have a constant defined in your class which provides max line count to show initially (along with read more) button
// here for example, you want to show 5 lines along with read more button
private static final int DEFAULT_DESCRIPTION_LINES_PORTRAIT = 5;
Now, as soon as you set your text, you check whether your text's line count is less than 5 or not. If it's less than 5 then you don't need to show read more button at all. If it's more than 5 then you would set maxLines of that TextView to your default lines. Also you'll make read more button visible
textView.setMaxLines(DEFAULT_DESCRIPTION_LINES_PORTRAIT);
readMorebutton.setVisibility(View.VISIBLE);
Now, you'll simply toggle maxLines to either default or actual line count whenever user presses on that button. Along with that make readMoreButton visibility gone to visible respectively.
Also it might be possible that TextView layout inflation takes time, so you might want to run a runnable on post of that TextView so that you're sure whenever you call textivew..getLineCount(); then you'll get correct value.
Regarding that gradient on top of button, you may simply have that button along with full width view on top of it (which would have a gradient background) in a vertical LinearLayout.
I hope this helps.
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.
Suppose, I need the user to be able to input a list of strings somewhere in the settings of the app. Say, it's a list of URLs. The strings are not supposed to have any spaces, commas or semicolons inside.
The easiest thing I thought of so far is to make a big multi-line EditText with a hint to the user "Separate strings by spaces" and each time the user presses OK, use split(" ") to extract the array of strings.
The problem with that simple solution is that sometimes strings are not long enough to fill the whole EditText width, and >1 strings appear visually in 1 line. Sometimes the URLs are too long, so "www." remains on one line, and the rest of the address appears on the next line. It all looks messy and the user looses track where separate URLs start and end in the line.
Another easy solution: a long single-liner where all strings are separated by ; with optional spaces after. VisualStudio uses that in settings, I find it bad as well since you don't see all the strings at once and have to move in this long line a lot (even harder with the clumsy touch screen).
A more expensive solution: a vertically scrollable list of single-line EditTexts, which are generated programmatically each time the settings screen is opened. Would also need a "+" button which creates a new EditText and a "-" button next to each of the existing EditText's.
EDIT: Another idea: show all the strings in a plain ListView with a "+" button in the last row. When you tap "+", it turns into an EditText with 2 buttons to the right: "OK", "Cancel". "OK" would save the newly added string.
If the user taps any of the items in the list, the line turns into an EditText with "OK" and "Delete" button. "OK" saves edits, "Delete" deletes the item. "OK" and "Delete" buttons better should have images instead of words.
Or, well, all strings can be shown in a ListView, and each time the user taps on an item, an additional popup is shown with EditText for editing the string and 3 buttons below: "OK", "Cancel" and "Delete".
Am I thinking along the right lines? Do you know any existing patterns/libraries/solutions which solve this problem efficiently on touch screens?
It would be better, to have only a single editText, where user can set values in list one by one, and can see added values in listView, There may be some provision for a button to save all entered data, onve. See following link once,
http://www.mubasheralam.com/tutorials/android/listview-transcript-mode
IMHO touch screens are not made for extensive writing since the touch keyboards are awful for writing stuff too long or with too much symbols (e.g. programming language or URL). Do not think about touch apps like old desktop apps/systems. Maybe you should rethink your design and try to avoid this data input.
If it's something your app cannot live without, or you simply do want to do it that way anyway:
I think a newline separator is way more clear than a space or a ";" (assuming the URLs cannot contain ";" btw...).
What about one EditText for each URL, generating EditTexts programatically as the previous one is filled.
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.