Android Circle button background problems - android

I have created circle button in photoshop. When I saved it in photoshop I deleted background box what was behind my button. And when I opened it with photoviewer there wasn't any background there was only a circle. But when I put ImageButton in Android then there is a white box. How can I remove this box behind my button?

It might be the default background. Try setting the android:background attribute to transparent.
android:background="#android:color/transparent"

Related

click button color spread all over the screen

I have an android application where when I click on a button (made with a Textview) I have a brief change background color (black to green) before changing of activity.
Sometimes, things go wild and the green color spread on other elements.
Green color everywhere instead of black background with bottom button which can become green on click:
Actually I am not sure at all that the green come from the button on click color. It might be another reason.
How can I get rid of this bug.?
Thank you for your help
I finally forced the background color programmatically in the onCreate...

Change background color of circular button android

I have a button in android which I have made circular in shape. Also I have an xml which changes the background color on pressed, but the color goes back to normal after the pressed state is changed.
I made the following change to code
arg0.setBackgroundColor(getResources().getColor(R.color.greenText));
But now the background takes rectangular shape and not the oval shape.
Okay as you have said the background shape changes when using setBackgroundColor, i think here's what you want,
1.you might be interested in color filters like this
Button btn = (Button) findViewById(R.id.button1);
btn.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFFAA0000));
You use different values according to your required colour.If you want to know the constant values of colours, you can refer the documents.
2.you can programmatically set the shade of the entire button using the PorterDuff multiply mode. This will change the button colour rather than just the tint.
For example for a red shaded button
btn.getBackground().setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY);
For a green shaded button
btn.getBackground().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);
And so on.What it actually does is, it works by multiplying the current button colour value by your colour value.
3.You can also use an online tool like this Android Button Maker to customize your button and use android:background="#drawable/custom_btn" in your layout(inside the tag) to define the customized button.
Now i believe there are more ways to achieve what you want but i think these are some easy and quick fixes you can use.Hope this helps.

Android ImageButton - How to hide the image while showing the background?

I've read the API and Googled but perhaps I've missed something: All the visibility options on an ImageButton seem to talk about this view as a whole. So, what should I do if I want to hide the image but keep the background(except for explicitly setting the image to something transparent that is)? I'm doing a Pairs Game and when one clicks on the element it should show the image and if the next click doesn't match the image should be hidden, but the grey background of the button should remain.
Thanks!
So, what should I do if I want to hide the image
Try setting it to #null or create transparent PNG in your drawables and set it.
in XML, remove android:src="something" and in the code remove imgbtn.setImageBitmap(null);
Instead of using ImageButton you can use ImageView with a FrameLayout on top of it. Set the background of FrameLayout as gray color and then show/hide this FrameLayout/Image as per your requirement. Take relative layout for each and make it clickable. On the click event of this layout, do the changes as required.

How yo add glowing effect on button with background?

I have taken a button in my xml and set its background img1 now on the click of that button i want white glow around that button edges . I have refereed this links http://developer.android.com/guide/topics/ui/controls/button.html Android ImageButton with a selected state? Standard Android Button with a different color
You can add a white border to the button. please enter this question to see how to add border: Android - border for button
Store the xml in
res/drawable/filename.xml
And then you can access it like this:
In Java: R.drawable.filename
In XML: #[package:]drawable/filename

How to create an iOS style arrow button in Android?

I am partial to dual use buttons in iOS, like in the image below:
How can I create these types of buttons in Android? In other words, the entire button must be clickable, the arrow must be right-aligned and the text of the button must be left aligned.
I tried playing with a regular Button widget, but no luck. Do I have to resort to a Table layout (but then the clickability would be lost).
You will need customized shape background for the Button
You can find customizing shape here.
Set that background to the Button from xml, and for showing arrow, you will need to add arrow.png to your project drawables.
you will add attribute to button like this:
<Button android:backround="#drawable/cell_background"
android:drawableRight="#drawable/arrow" ... />

Categories

Resources