1

是否可以创建一个倾斜的形状按钮?
(即像从屏幕左下角到屏幕右上角的条纹形状,而不是常规的方形或矩形按钮)?

像这张图片http://www.codeproject.com/KB/silverlight/SilverLightFAQPart2/9.JPG
我需要确保可点击区域也只是彩色区域。

谢谢,

球座

4

2 回答 2

0

您需要为此编写自己的课程。只需子类 View 并监听 onClick 事件。

于 2010-03-13T05:38:55.793 回答
0

尝试使用选择器作为背景。

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

然后在您的可绘制文件夹中创建一个my_button.xml

<?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>

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

于 2010-03-13T10:12:10.193 回答