
我该怎么办?
示例链接/代码非常感谢.
解决方法 你想使用 Android的Shape Drawables.http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
绘制/ cool_button_background.xml
<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shape="rectangle"> <corners androID:radius="@dimen/corner_radius" /> <gradIEnt androID:angle="270" androID:startcolor="@color/almost_white" androID:endcolor="@color/somewhat_gray" androID:type="linear" /></shape>
那么你必须从这些形状可绘制中创建一个“选择器”.这使您可以根据状态使按钮显示不同. IE:按压,聚焦等
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
绘制/ cool_button.xml
<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <item androID:state_pressed="true" androID:drawable="@drawable/cool_inner_press_bottom" /> <item androID:state_focused="true" androID:state_enabled="true" androID:state_window_focused="true" androID:drawable="@drawable/cool_inner_focus_bottom" /> <item androID:drawable="@drawable/cool_button_background" /></selector>
奖金:您可能想要为该按钮创建一个样式,以便您可以在整个程序中保持一致.你可以剪出这个步骤,只需设置按钮的androID:background =“@ drawable / cool_button”.
价值观/ styles.xml
<?xml version="1.0" enCoding="utf-8"?><resources> <style name="MyCoolbutton"> <item name="androID:background">@drawable/cool_button_background</item> </style></resources>
最后,按钮!
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:orIEntation="vertical" androID:background="@drawable/appWidget_bg"> <button androID:ID="@+ID/btnAction" androID:layout_wIDth="wrap_content" androID:layout_weight="wrap_content" /></linearLayout>总结
以上是内存溢出为你收集整理的圆形角落按钮与背景颜色在Android全部内容,希望文章能够帮你解决圆形角落按钮与背景颜色在Android所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)