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

Android實(shí)現(xiàn)水波紋點(diǎn)擊效果

 更新時(shí)間:2017年03月02日 11:55:49   作者:Android_yyx  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)水波紋點(diǎn)擊效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

Android實(shí)現(xiàn)水波紋點(diǎn)擊效果只在Android5.0以上版本有效,水波紋點(diǎn)擊效果代碼供大家參考,具體內(nèi)容如下


圓角背景的水波紋效果(如上圖)

1. 定義一個(gè)普通圓角背景的xml;

rounded_corners.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <solid android:color="#FFFFFF" />
 <corners android:radius="4dp" />
</shape>

2. 這里是重點(diǎn),<ripple>是API21才有的新Tag,正是實(shí)現(xiàn)水波紋效果的;
其中<ripple Android:color="#FF21272B" .... />這個(gè)是指定水波紋的顏色,而<item />里面的東西,我們都很熟悉,就是普通的定義一個(gè)帶圓角的背景。

ripple_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
 android:color="#FF21272B">
 <item>
  <shape android:shape="rectangle">
   <solid android:color="#FFFFFF" />
   <corners android:radius="4dp" />
  </shape>
 </item>
 <item android:drawable="@drawable/rounded_corners" />
</ripple>

3. 這是Activity的布局xml;

<Button android:background="@drawable/ripple_bg"... />直接使用ripple_bg作為背景。

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:gravity="center"
 android:orientation="vertical"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context=".MainActivity">

 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="@string/hello_world" />

 <Button
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@drawable/ripple_bg"
  android:text="@string/hello_world" />
</LinearLayout>

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論