• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Android 实现各种形状和颜色的按钮

武飞扬头像
ys.journey
帮助1

Android 实现各种形状的按钮

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 设置固定填充色 -->
<solid android:color="#f00" /> //颜色可以自己设定
<size android:width="60dp" android:height="30dp"/>
</shape>

看一下效果:
学新通
形状2:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置渐变填充色 -->
    <gradient android:startColor="#00f" android:centerColor="#0f0" android:endColor="#f00"></gradient>
</shape>

学新通
形状3:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke 
        android:width="2dp" 
        android:color="#f00" >
    </stroke>
</shape>

学新通
形状4:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边 -->
	<stroke
		android:width="2dp" 
		android:color="#f00" 
		android:dashWidth="5dp"
		android:dashGap="5dp">
	</stroke>
</shape>

学新通
形状5:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke 
        android:width="2dp" 
        android:color="#f00" 
        android:dashWidth="5dp" 
        android:dashGap="5dp"></stroke>
    <corners android:radius="15dp"/>
</shape>

学新通
形状6:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- 设置固定填充色 -->
    <solid android:color="#f00" />
    <size 
        android:width="60dp" 
        android:height="30dp"/>
    <corners android:radius="10dp"/>
</shape>

学新通
形状7:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置渐变填充色 -->
    <gradient 
        android:startColor="#f00" 
        android:centerColor="#0f0" 
        android:endColor="#00f" 
        android:gradientRadius="60"
        android:type="radial"></gradient>
</shape>

学新通
形状8:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke android:width="2dp" android:color="#FFBB86FC" ></stroke>
    <corners android:radius="15dp"/>
</shape>

学新通
形状9:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置渐变填充色 -->
    <gradient android:startColor="#4169E1"
        android:centerColor="#D2691E"
        android:endColor="#87CEFA"
        android:type="sweep">

    </gradient>
</shape>

学新通
形状10:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边 -->
    <stroke 
        android:width="2dp" 
        android:color="#f00" 
        android:dashWidth="5dp" 
        android:dashGap="5dp">
    </stroke>
    <corners 
        android:radius="15dp" 
        android:topRightRadius="0dp" 
        android:bottomRightRadius="0dp"/>
</shape>

学新通
形状11:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <!-- 设置固定填充色 -->
    <solid android:color="#48D1CC" />
    <size android:width="60dp" android:height="30dp"/>
</shape>

学新通
形状12:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置渐变色 -->
    <gradient 
        android:startColor="#00f" 
        android:centerColor="#0f0" 
        android:endColor="#f00"></gradient>
</shape>

学新通
形状13:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边色 -->
    <stroke
        android:width="2dp"
        android:color="#f00" >
    </stroke>
</shape>

学新通
形状14:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <size android:width="60dp" android:height="30dp"/>
    <!-- 设置描边色 -->
    <stroke 
        android:width="2dp" 
        android:color="#f00" 
        android:dashWidth="5dp" 
        android:dashGap="5dp">
    </stroke>
</shape>

学新通
形状15:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="20dp"
    android:shape="ring"
    android:thickness="2dp"
    android:useLevel="false" >
    <!-- 设置固定填充色 -->
    <solid android:color="#f00" />
    <size
        android:height="20dp" />
</shape>

学新通
形状16:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="20dp"
    android:shape="ring"
    android:thickness="2dp"
    android:useLevel="false" >
    <!-- 设置渐变填充色 -->
    <gradient 
        android:startColor="#00f" 
        android:centerColor="#0f0" 
        android:endColor="#f00"/>
    <size
        android:height="44dp"/>
    <stroke 
        android:width="2dp" 
        android:color="#f00" 
        android:dashWidth="5dp" 
        android:dashGap="5dp"/>
</shape>
学新通

学新通
形状17:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <stroke
        android:dashGap="8px"
        android:dashWidth="8px"
        android:width="1dp"
        android:color="#f00" />
    <size android:height="30dip" />
</shape>

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfagjb
系列文章
更多 icon
同类精品
更多 icon
继续加载