android---制作一个自定义button

这篇博文是新手作者关于Android自定义View的学习记录,主要讲解如何创建一个自定义的Button。内容包括在布局文件中使用自定义Button,以及通过CusSetMonitorDistanceBar.java文件和drawable资源来实现其特定属性的设置。
摘要由CSDN通过智能技术生成

本人新手,刚学android。记录下一些容易忘记的东西,都是自己瞎琢磨理解的,不一定正确,往高手指正,同时,不建议其他新手参考(容易被带到沟里,慎看)


这是第一个博文,制作一个button。



1、先看怎么用它,将它放在布局文件中。

在main.xml中的某个位置:

 <com.lei.widget.DimPanelBottomBar
                android:id="@+id/btn_bootom_bar"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8.0dip"
                custom:left_text="@string/cancel"
                custom:left_text_color="@color/button_cancel_color"
                custom:right_text="@string/confirm"
                custom:right_text_color="@color/button_confirm_color" />
好了,我们可以看到它有几个属性是以custom开头的,它们是这个控件特有的东西,是我自定义添加进去的属性。好了,我们去valuse/attrs中定义这些特有的属性(show_my_style属性是多余定义的,暂时没有用到,不用理会)

 <declare-styleable name="CusSetMonitorDistanceBar">
       <attr name="leftText" format="string" />
       <attr name="leftTextColor" format="string" />
       <attr name=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值