欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android自定義形狀的按鍵實(shí)例代碼

 更新時(shí)間:2018年05月03日 11:03:32   作者:qq_37217804  
這篇文章主要介紹了android自定義形狀的按鍵實(shí)例代碼,本文分步驟給大家介紹的非常詳細(xì),需要的朋友可以參考下

步驟:

1.在drawable 文件夾中創(chuàng)建一個(gè)xml布局文件。

2.修改布局文件

3.在需要使用背景的按鍵中導(dǎo)入布局。

創(chuàng)建布局文件:

修改布局文件:

<?xml version="1.0" encoding="utf-8"?> 
<!--shape:形狀 rectangle 長(zhǎng)方形--> 
<!--corners 邊角--> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
  android:shape="rectangle"> 
  <!--設(shè)置背景顏色--> 
  <solid android:color="@color/colorblue"/> 
  <!--設(shè)置角為半圓 radius 半徑--> 
  <corners android:radius="10dp"/> 
  <!--bottom 下 top 上 left左 right右--> 
  <padding 
    android:bottom="10dp" 
    android:left="10dp" 
    android:right="10dp" 
    android:top="10dp" 
    /> 
</shape> 

預(yù)覽效果圖:

在按鍵中添加布局:

實(shí)際效果:


PS(橢圓按鍵的xml):

<?xml version="1.0" encoding="utf-8"?> 
<!-- shape 形狀 oval橢圓形--> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
  android:shape="oval"> 
  <!--設(shè)置背景顏色--> 
  <solid android:color="@color/colorgreen"/> 
  <!--設(shè)置高度和寬度--> 
  <size android:height="30dp" 
    android:width="120dp"/> 
  <padding 
    android:bottom="10dp" 
    android:top="10dp" 
    android:left="10dp" 
    android:right="10dp"/> 
</shape> 

總結(jié)

以上所述是小編給大家介紹的android自定義形狀的按鍵實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論