<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >        <!-- 圆角 -->    <corners        android:radius="9dp"        android:topLeftRadius="2dp"        android:topRightRadius="2dp"        android:bottomLeftRadius="2dp"        android:bottomRightRadius="2dp"/><!-- 设置圆角半径 -->        <!-- 渐变 -->    <gradient        android:startColor="@android:color/white"        android:centerColor="@android:color/black"        android:endColor="@android:color/black"        android:useLevel="true"        android:angle="45"        android:type="radial"        android:centerX="0"        android:centerY="0"        android:gradientRadius="90"/>        <!-- 间隔 -->    <padding        android:left="2dp"        android:top="2dp"        android:right="2dp"        android:bottom="2dp"/><!-- 各方向的间隔 -->        <!-- 大小 -->    <size        android:width="50dp"        android:height="50dp"/><!-- 宽度和高度 -->        <!-- 填充 -->    <solid        android:color="@android:color/white"/><!-- 填充的颜色 -->        <!-- 描边 -->    <stroke        android:width="2dp"        android:color="@android:color/black"        android:dashWidth="1dp"        android:dashGap="2dp"/>    </shape>


填充:设置填充的颜色

间隔:设置四个方向上的间隔

大小:设置大小

圆角:同时设置五个属性,则Radius属性无效

android:Radius="20dp" 设置四个角的半径

android:topLeftRadius="20dp" 设置左上角的半径
android:topRightRadius="20dp" 设置右上角的半径
android:bottomLeftRadius="20dp" 设置右下角的半径
android:bottomRightRadius="20dp" 设置左下角的半径

描边:dashWidth和dashGap属性,只要其中一个设置为0dp,则边框为实现边框

android:width="20dp" 设置边边的宽度
android:color="@android:color/black" 设置边边的颜色
android:dashWidth="2dp" 设置虚线的宽度
android:dashGap="20dp" 设置虚线的间隔宽度

渐变:当设置填充颜色后,无渐变效果。angle的值必须是45的倍数(包括0),仅在type="linear"有效,不然会报错。android:useLevel 这个属性不知道有什么用。

angle对应值的起点如图:



参考:

http://kofi1122.blog.51cto.com/2815761/521605/



这里补充一下其他的:

XML file saved at res/color/button_text.xml:

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">  <item android:state_pressed="true"     android:color="#ffff0000"/> <!-- pressed -->  <item android:state_focused="true"     android:color="#ff0000ff"/> <!-- focused -->  <item android:color="#ff000000"/> <!-- default --></selector>

This layout XML will apply the color list to a View:

<Button  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text="@string/button_text"  android:textColor="@color/button_text" />


更多相关文章

  1. Android(安卓)Notification 通知
  2. Android(安卓)Studio 初体验
  3. Android如何在java代码中设置margin
  4. Android(安卓)Studio中设置ButterKnife、android butterknife ze
  5. android WebView全屏观看视频 全屏观看直播
  6. android:configChanges属性总结
  7. Android中设置文本颜色的三种方法
  8. 通过XML设置屏幕方向(android:screenOrientation)详解
  9. 后台动态添加布局文件、控件与动态设置属性

随机推荐

  1. Android中声音的管理类AudioManager
  2. 转载:Android开源项目分享
  3. Android下自定义IP控件
  4. 使用Android平板编程,执行linux命令
  5. Android(安卓)读取doc文件
  6. android的振动器Vibrator
  7. android中怎么获得所有应用程序的快捷方
  8. Android(安卓)adb shell 启动java程序
  9. as gradle debug\values\generated.xml
  10. Android(安卓)和 PHP 之间进行数据加密传