public class cButton extends Button{
public OnPressButton(Context context) {
super(context);
}
public OnPressButton(Context context, AttributeSet attrs){
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
//sets the button image based on whether the button in its pressed
state
setBackgroundDrawable(getResources().getDrawable(isPressed()?
R.drawable.btn_on : R.drawable.btn_off));
super.onDraw(canvas);
}
}
Then instead of using the Button widget, use the above implementation
of Button in your layout xml file.
<view
class="com.mycompany.android.ui.OnPressButton"
android:background="@android:color/transparent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Button" />
http://bend-ing.blogspot.in/2008/10/android-how-to-implement-custom-button.html
Moktarul
On Feb 17, 1:53 pm, shihab shiha <[email protected]> wrote:
> 2. create cbutton extent Button and override onDraw method and then
> instate of button use cbutton
> Can you explain this one little widely. I tried the first one but it
> doesnt give the exact solution what i expect
>
>
>
>
>
>
>
> On Fri, Feb 17, 2012 at 1:08 PM, moktarul anam <[email protected]> wrote:
> > you can do this two way
> > 1. set background 2 some drawable xml file and then customize there
> > 2. create cbutton extent Button and override onDraw method and then
> > instate of button use cbutton
>
> > Enjoy
> > Moktarul
>
> > On Feb 16, 1:45 pm, value makers <[email protected]> wrote:
> > > Hi All,
>
> > > I am new in android development. I have one problem regarding with my
> > > button customization. i would like to customize a button in a semi
> > > circular form .
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en