Here I indicate with red arrow that I want to create possible. By default Selecteditembackground is not rounded on android. But I need to make it rounded like this Image . How ???
I would create 2 Images for my button. One without a backround and one with backround. Then I would use a ToggleButton and would assign my two images for the two states checked an unchecked. You could also use a regular ImageButton for that and switch between the images onClick. By doing so you can create every design you wish.
Related
I have two png-images for the pressed and released state of a button. I'd like to build a button that accomplishes the following:
Has no background/border (only those two images visible)
Does not highlight with a blue rectangle when clicked (only by cycling through those images)
Does not get activated, when the user clicks on a transparent part of the image.
As you can see, the button is not rectangular, so the last point mentioned above might be tricky.
I already tried to use an ImageButton and managed to meet point 1, but I failed at point 2.
Is there another View I can use, that does the work for me? If not, could you hint me what techniques I should look into to solve this?
Just use ImageView
One image set as background, second as src.
And it resolve all your problems
[Edit]
for third part- follow this https://stackoverflow.com/a/8086317/3811198
in short
Use a TouchListener instead of ClickListener
Inside the listener, if the event is MotionEvent.ACTION_DOWN, get the touch coordinates
Check the image's pixel at the coordinates you obtained earlier; if the pixel is not transparent, consider the button was clicked, otherwise ignore the event.
If you use setBackground = "#0xxx"; on button in xml file the borders will desappear. Basically making it transparent using alpha
android:setBackground = "#0AAA"
I have an image for a button. Here it is:
My task is to create a selected and unselected state of this image. This image will be my unselected state.
Using the same image, my task is to create a selected button with darker background. Is it possible to darken the image in Java?
NOTE:
I have knowledge that I can do this my using an external software and have another image for selected button. However, should my idea be real and was already implemented in Android, it would actually benefit more people. So, upon research, I have not found possible ways to do this. If this is possible, surely I have missed something great.
Ideally you can have a darker image and when clicked in onClick() of onClickListener you can set the alpha setAlpha of this image to 0.5 or you need to implement selectors with two different images/states.
What's a good way, both layout- and codewise, to accomplish the following:
Display one or more clickable images on the screen.
By default, the images are default images (duh)
When clicking on them, they change to a specified image
When clicking again, the change back to the default image
I cannot set all the images in the xml layout file(s), since I must be able to programatically set and change the images when clicking, and keep a record of the images on display etc.
In case anyone wonders: Yes, this is supposed to be a simple "memory" game, where I show x images, and click on two of them to display them, and give a result if they're identical.
I would suggest you to use ImageSwitcher, as the view, and setOnClickListener on the ImageSwitcher, to apply image changes on click action.
I have created a shiny button in photoshop and now wish to use it for the background of a button on an android layout. Every time I change the buttons buttons background property it inserts the button but it does not fill the entire background but instead seems to push the boundaries of the button away from it as if there were huge amounts of padding! I have not altered the buttons padding properties either! I have previously been successful in filling the buttons entire background with buttons already created that I downloaded from the internet but I dont know if the were created in photoshop......however I did resize these buttons in photoshop and then successfully use them. Please see the image attached and notice the blue outline of the button whose background I am trying to fill! Any help is greatly appreciated!!!!
Try this: http://developer.android.com/guide/developing/tools/draw9patch.html
I need to create some custom buttons as shown in the image below
what is the best approach to follow?
thanks
Abdul Khaliq
That's a hard one. I made a lot of custom views, and the first thing I would thinking of is, made one Button with that above image, and handle onTouch by yourself so you can distinguish which area the user hit. There you can also change the state of the button, like changing the image to a bevel one e.g. when the left button is hit.
Can you imagine this ansatz?
You can place two transparent "invisible" buttons over the top of a background in a LinearView. Like two ImageButtons with a transparent png inside.
It is also possible to make this background animated when buttons are clicked using android animation class.