設定Button背景漸變效果和點選效果

2021-06-07 17:57:48 字數 718 閱讀 2092

1、設定背景漸變效果,在drawable目錄下建buttonshape.xml檔案,

內容為:

<?xml version="1.0" encoding="utf-8"?> 

" android:shape="rectangle">  

這裡startcolor是開始顏色,endcolor是漸變結束顏色,預設是從上往下漸變,可以使用android:centery調節,android:angle="270"設定角度。

corners設定邊角的圓滑度。

設定點中的效果,在drawable目錄下建buttonshape_down.xml檔案,內容如下:

<?xml version="1.0" encoding="utf-8"?> 

"android:shape="rectangle">   

在res目錄下新建資料夾xml,然後在xml目錄下,新建selectshape.xml檔案,內容如下:

<?xml version="1.0" encoding="utf-8"?> 

">   

state_pressed設定按鈕狀態,在main.xml檔案中設定button的屬性:

使用background設定按鈕的背景色。

設定Button背景漸變效果和點選效果

1 設定背景漸變效果,在drawable目錄下建buttonshape.xml檔案,內容為 android shape rectangle 這裡startcolor是開始顏色,endcolor是漸變結束顏色,預設是從上往下漸變,可以使用android centery調節,android angle ...

設定button背景的半透明效果!!!

android layout width fill parent android layout height fill parent android orientation vertical android background drawable bg package com.guo.mygridv...

VTK設定漸變背景色效果

最近想在自己的矩量法軟體中設定漸變背景色效果,查了vtk手冊及原始碼終於找到了方法,此處記錄一下,以防遺忘。vtk場景中的背景色可通過新增的renderer來 設定。vtk的繪製過程網上有一堆資料,此處只記錄背景色設定部分。renderer setbackground 1.0,1.0,1.0 設定頁...