开发者

Android - Skewed button

is it possible to create a skewed shape button?

(i.e like a stripe shape from bottom left of screen to top right of screen instead of the regular square or rectangle shape button)?

开发者_开发知识库

Something like this image http://www.codeproject.com/KB/silverlight/SilverLightFAQPart2/9.JPG

And I need to make sure the clickable area is also just the colored one.

Thanks,

Tee


You'd need to write your own class for that. Just subclass View and listen for the onClick events.


Try using a selector as background.

    <Button 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello" 
        android:background="@drawable/my_button" 
    /> 

And then make a my_button.xml in your drawable folder.

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/focused" /> 
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" /> 
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" /> 
    <item android:drawable="@drawable/defaultbutton" /> 
</selector>

Source: http://www.anddev.org/tinytutcustom_button_backgrounds-better_imagebutton-t4298.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜