Samsung button click effect - android

While I was creating Calculator app same as installed in my S6 edge, I stuck when
design buttons. I want to make buttons look exactly same as calc app which comes in all samsung phones.I tried state button pressed but they have design like fading colors in and out for seconds which I ain't sure how to create.

by simple way create new xml file called clickable_button.xml
inside it write this code
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/button_clicked" android:state_pressed="true"/>
<item android:drawable="#drawable/button"/>
</selector>
don't for get to make two drawable files one seem clicked and another not clicked
finally set your button background with clickable_button ;)

Related

How to add a click effect to a button on click event?

How would I add a click effect similar to the below image for a button click event?
The button in my activity already has it's background set to an image so I'm not sure how I would add a background of a state also as in this tutorial:
Android Button color changing on onClick?
You need two image, one for normal state and another for pressed state. At first create a selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/pressed_image" android:state_pressed="true"/>
<item android:drawable="#drawable/normal_image"/>
</selector>
Add this selector in your button as a background.
Here's something similar. I am not sure though, if this fits your solution.
EDIT: It uses selector, just like #Raghunandan suggested above.

How to make a non-holo button with DialogFragment

I am building an application to show a dynamic picture and a dialog with a button. The thumbnail of that picture is then used as the background of the button. However, if the picture is with black pattern, it turns out showing as "holo" and transparent to the background. This makes the button ugly.
I am trying this on android 4.x.
I have tried using different themes for the dialog, Theme.Dialog, Theme.Holo and Theme.Light but no luck.
My problems are
(1) how to make a non-holo button with DiaglogFragment(even on a holo theme view/activity).
(2) is this related to android versions? or machines?
Thank you.
you need to create a selector with all the different states of a button and for each state you will need an image
for example
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#drawable/blue_curve" android:state_enabled="true" android:state_pressed="false"/>
<item android:drawable="#drawable/blue_curve_pressed" android:state_pressed="true"/>
</selector>
then set the background to the selector in your xml

Android Custom Button Pressed State

I am trying to change the appearance of an Android Button, but I can't get it to work. I use this code in "custom_button.xml" to handle the drawing of the button:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="#drawable/btn_normal"
/>
<item android:drawable="#drawable/btn_over"
android:state_pressed="true"/>
In my layout file I set the button's background to the custom_button drawable. The normal state works (the one that first appears), but when the button is pressed the image doesn't change. I double checked to make sure I am using different images and I am. Does anyone know why this isn't working?
Thanks!
Switch the order of the items (so pressed first, then neutral). Pressed or not, the top item is always true.

Fancy Button with animation

I want to create a 2-state-switch button (on/off) like in doubletwist alarm clock
-> http://www.design-by-izo.com/wp-content/uploads/2012/03/Screenshot_2012-03-30-20-11-30.png
When pressing the button it switches its caption with a fancy slide-in effect.
I already know about android animations, but anyhow I dont get this work within a single view.
EDIT: is there any way to do this, prior to ICS? (without taking ICS' code...)
Any Idea?
You're looking for an android switch - It's already been done for you. You just need to supply your own custom images for the switch's style
There is no slide effect on Android like on iPhone. However doing a two-state btn is easy. Just create an xml file like this and put the drawables in the folder:
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="#drawable/my_btn_pressed_bkgnd" android:state_pressed="true"/>
<item android:drawable="#drawable/my_btn_disabled_bkgnd" android:state_enabled="false"/>
<item android:drawable="#drawable/my_btn_unpressed_bkgnd" android:state_enabled="true"/>

custom android button look and feel

The two buttons in the bottom of the screen are Scan and Leads, if we click on any button, the view of the button is visible like pressed as u see in image for lead button, this view will change according to the button click, and here i am unable to create that kind of look and feel for buttons. please provide me the sample code or suggest me to achieve this look and feel.
Thanking you
this is custom button .A custom button is very easy to create, you just have to make different images for the different state of the button and place it into your res/drawable folder.
below link contain the step by step description for creating this:
http://androidemulator.wordpress.com/2011/11/03/creating-custom-buttons-in-android-applications/
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/button_some_name_pressed" android:state_pressed="true"/>
<item android:drawable="#drawable/button_some_name_default"/>
</selector>
Have this in your /drawable/ folder as button_some_name.xml
Then have the button_some_name_pressed.png & button_some_name_pressed.png in your drawable-ldpi drawable-mdpi etc
There are other states to consider as well
ref: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Categories

Resources