網站首頁 編程語言 正文
效果:點擊變灰
創建個xml放在drawable下
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape>
<!--背景-->
<solid android:color="#ffffff"/>
<!--邊框-->
<stroke android:color="#BF464649"
android:width="1dp"/>
<!--圓角-->
<corners android:radius="30dp"/>
<!--邊距-->
<padding android:bottom="2dp"
android:top="2dp"
android:right="6dp"
android:left="6dp"/>
</shape>
</item>
<item android:state_pressed="true">
<!-- 點擊時背景變灰-->
<shape>
<!--背景-->
<solid android:color="#7E222323"/>
<!--梯度-->
<gradient android:startColor="#7E222323" android:endColor="#7E222323" />
<!--邊框-->
<stroke android:width="2dp" android:color="#7E222323" />
<!--圓角-->
<corners android:radius="30dp" />
<!--邊距-->
<padding android:bottom="2dp"
android:top="2dp"
android:right="6dp"
android:left="6dp"/>
</shape>
</item>
</selector>
使用
android:background="@drawable/button_style"
例子:
<Button
android:id="@+id/views_close"
android:layout_width="50px"
android:layout_height="50px"
android:layout_marginLeft="20px"
android:layout_weight="1"
android:background="@drawable/button_style"
android:text="關" />
原文鏈接:https://blog.csdn.net/qq_42834405/article/details/116589559
相關推薦
- 2022-06-12 python文件操作的基礎詳細講解(write、read、readlines、readline)_p
- 2022-10-14 TimeDateUtils日期時間工具類
- 2022-11-27 C++中順序表操作的示例代碼_C 語言
- 2022-07-19 mybatis plus 代碼生成器配置
- 2022-05-16 .Net?MVC將Controller數據傳遞到View_實用技巧
- 2022-05-17 IDEA自帶maven報錯maven-default-http-blocker (http://0.
- 2022-08-13 Linux管理員root密碼忘記了怎么辦?
- 2021-12-02 C++?函數的介紹_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支