Android開發(fā)實(shí)現(xiàn)的圓角按鈕、文字陰影按鈕效果示例
本文實(shí)例講述了Android開發(fā)實(shí)現(xiàn)的圓角按鈕、文字陰影按鈕效果。分享給大家供大家參考,具體如下:
效果圖:

如果要實(shí)現(xiàn)圓角圖片,并變色須在drawable中配置背景文件如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圓角深紅色按鈕 -->
<solid android:color="@color/RED"/>
<corners android:radius="15dip"/>
</shape>
</item>
<item android:state_pressed="false">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圓角紅色按鈕 -->
<solid android:color="@color/PURPLE"/>
<corners android:radius="15dip"/>
</shape>
</item>
</selector>
三個(gè)按鈕整體布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--文字帶陰影的按鈕-->
<!--陰影模糊程度:android:shadowRadius="5"-->
<!--陰影與文字的距離:android:shadowDx="20"-->
<!--android:shadowDy="20"-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="文字帶陰影的按鈕"
android:textSize="20pt"
android:shadowColor="#aa5"
android:shadowRadius="5"
android:shadowDx="20"
android:shadowDy="20"/>
<!--普通文字按鈕-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#836622"
android:text="普通按鈕"
android:textSize="20pt"/>
<!--帶文字的圖片按鈕-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_selector"
android:textSize="20px"
android:text="帶文字的按鈕"/>
</LinearLayout>
顏色RED和PURPLE的宏定義:
<color name="RED" >#ff0000</color> <color name="PURPLE" >#9a32cd</color>
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android控件用法總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》及《Android資源操作技巧匯總》
希望本文所述對大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
Android notifyDataSetChanged() 動(dòng)態(tài)更新ListView案例詳解
這篇文章主要介紹了Android notifyDataSetChanged() 動(dòng)態(tài)更新ListView案例詳解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
Android 實(shí)現(xiàn)沉浸式狀態(tài)欄的方法
沉浸式狀態(tài)欄的來源就是很多手機(jī)用的是實(shí)體按鍵,沒有虛擬鍵,于是開了沉浸模式就只有狀態(tài)欄消失了。下面腳本之家小編給大家介紹Android 實(shí)現(xiàn)沉浸式狀態(tài)欄,需要的朋友可以參考下2015-09-09
Android中基于XMPP協(xié)議實(shí)現(xiàn)IM聊天程序與多人聊天室
這篇文章主要介紹了Android中基于XMPP協(xié)議實(shí)現(xiàn)IM聊天程序與多人聊天室的方法,XMPP基于XML數(shù)據(jù)格式傳輸,一般用于即時(shí)消息(IM)以及在線現(xiàn)場探測,需要的朋友可以參考下2016-02-02
Android數(shù)據(jù)加密之SHA安全散列算法
這篇文章主要為大家詳細(xì)介紹了Android數(shù)據(jù)加密之SHA安全散列算法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
Mac 下 Android Studio 不打印日志的解決辦法
這篇文章主要介紹了Mac 下 Android Studio 不打印日志的解決辦法的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-10-10

