Trying to create odd irregular shaped button - android

I am trying to create a keypad using Android Grid Layout. I would like one button that spans columns and rows in a 'L' Shape, for the Enter key.
See diagram. I have created a keypad and added the numeric buttons using Grid layout ok, but am struggling to work out if it is possible to span the rows and columns as I want to create the Enter Key.
Is this possible?
any hints tips or example code would be appreciated

A more elegant solution would be to create your buttons dynamically drawing filled touchable polygons on a canvas.
Take a look at "ImageMap for Android" (http://catchthecows.com/?p=113). It is really powerful, you can even create touchable charts.

Quick and dirty workaround: create a button (return) which is as big as 4 (2*2) of the regular ones.
Then put button 9 over it, top lef aligned.
It will work just fine

Related

Which layout should I use in android?

I make an app for boosting listening skills. I want to place several EditText like this:
When I enter some word I want that other words which placed on the right side will be lined break like this:
Eventually, If the EditBox reaches a screen border I want that he will be lined break with multiline edit property like this:
My question is which layout should I use and how to do it better. I need any ideas. Thank you.
Try to play with flexbox layout: https://github.com/google/flexbox-layout. It's a official google library.

Android - Custom EditText for Odometer Entry

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.

Background key on Keyboard Android

I want to do a part of a custom keyboard on Android like this:
I'm trying by:
android:keyIcon="#drawable/btn_del"
and
android:keyBackground="#drawable/btn_del"
beside
android:keyLabel="1 2 3"
to the first key. But it don't work.
How I can do this layout? (I have the grays image)
If I understood correctly, you are trying to change the order of the buttons, in the image you posted?
If that is so, then I would use a RelativeLayout and I would set an android:allignParentLeft="true" property for the "btn_del"
This would make it be the leftmost element.
All the others would have layout_toRightOf="id_of_the_previous_button", so that they would position to the right of eachother

¿Is it possible to put an icon with an action inside of EditText?

I'm looking forward to create an EditText with an Icon on the right that has some kind of functionality.
I've seen that the Google IO 2013 app has something like that on the search widget.
I want to know if its possible to do that with a simple EditText.
I've tried with a simple ImageView on the right of the EditText, but it looks really bad.
I would really appreciate if someone could point me in the right direction.
Thanks.
EDIT 1
This is an example of what I want. It looks really good. I have used the drawableRight and it doesn't look this good.
http://img836.imageshack.us/img836/1521/6faa.png
EDIT 2
I managed to build something that looks really similar to the SearchWidget with the voice recognition option.
I put two EditText next to each other (with a RelativeLayout), and set the margin left for the one on the right to -10dp. This way it looks like one EditText. I know this is not proper, but right now does what I want.
My problem now is the image, I'm using a 32x32 px image, because it fits fine, but it has really low quality, I'll look into that.
http://img560.imageshack.us/img560/9394/ilwp.png
You can definitely use a custom EditText with drawableRight as follows:
android:drawableRight="#drawable/your_drawable"
Refer
1.Custom EditText- 1
2.Custom EditText- 2

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