How yo add glowing effect on button with background? - android

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

Related

Android: Create diamond button with icon and text inside

I would please like to know how to create a diamond shaped button with an icon and text inside. Like in the image below. If i rotate the button then the image and icon get rotated too and if I create a custom shape/image to use as the background the buttons clickable area is still a square. Any help would be appreciated?
if you want change clickable area you have to intercept touch events and filter them. You need custom view for doing this

how to have string and image as a content of a button

I have a button in which I set its background a to 9 patch drawable and I set the text to some value. All works well. Now I want to add an image with the text (so text and image inside the button).
How can I do that?
Thanks
You can use styles in your button layout xml.
style="#style/settingTextView"
This will turn your button to the buttons you see in the settings APP. Then you can add left and right images to your button. Using -
android:drawableRight="#drawable/some_image_right"
android:drawableLeft="#drawable/some_image_left" android:text="#string/button_text"

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 Circle button background problems

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"

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