zoukankan      html  css  js  c++  java
  • 简单又好看的按钮,扁平化按钮。

    分享一下流行的扁平化按钮。完全不需要用到图片哦。效果图如下:

    里面有2个按钮都是一样的模式。只要修改的色值就可以。下面跟我来更新你的UI吧。

    首先编写 button.xml

    代码如下

    [html] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. <?xml version="1.0" encoding="utf-8"?>    
    2. <selector xmlns:android="http://schemas.android.com/apk/res/android">    
    3.     <!--点击背景-->    
    4.     <item android:state_pressed="true">    
    5.         <shape>    
    6.              <!--色值-->    
    7.             <solid android:color="#e79429" />    
    8.             <!--圆角-->    
    9.             <corners android:radius="10dp" />    
    10.         </shape>    
    11.     </item>    
    12.     <!--默认背景-->    
    13.     <item>    
    14.         <shape>    
    15.             <solid android:color="#f6aa3e" />    
    16.             <corners android:radius="10dp" />    
    17.         </shape>    
    18.     </item>    
    19. </selector>   


    然后使用方法如下:

    设置button的背景

    [html] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. <Button    
    2.             android:id="@+id/one"    
    3.             android:layout_width="wrap_content"    
    4.             android:layout_height="wrap_content"    
    5.             android:layout_marginTop="10dp"    
    6.             android:background="@drawable/button"    
    7.             android:paddingBottom="8dp"    
    8.             android:paddingLeft="25dp"    
    9.             android:paddingRight="25dp"    
    10.             android:paddingTop="8dp"    
    11.             android:text="我要赠送"    
    12.             android:textColor="@color/White"    
    13.             android:textSize="18sp" />    


    这样就完成了这个按钮。并且带有点击效果哦。

  • 相关阅读:
    1059 C语言竞赛
    1058 选择题
    1057 数零壹
    1056 组合数的和
    1055 集体照
    Mysql--分库分表
    Mysql--改表结构
    Mysql--开始阶段
    Mysql--常用语句
    Mysql--grant授权
  • 原文地址:https://www.cnblogs.com/labixiaoxin/p/5337432.html
Copyright © 2011-2022 走看看