日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Android中focusable屬性的妙用之底層按鈕的實(shí)現(xiàn)

在Android中使用focusable 屬性來實(shí)現(xiàn)按鈕的特效,看到百威啤酒的客戶端主界面的按鈕,感覺比較新奇,先看下圖片:

我們提供的服務(wù)有:成都做網(wǎng)站、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、尚義ssl等。為成百上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的尚義網(wǎng)站制作公司

注意圖中我畫的箭頭,當(dāng)時鼠標(biāo)點(diǎn)擊的黑色圈圈的位置,然后按鈕出現(xiàn)了按下的效果(黃色的描邊)

剛開始看到這種效果很是好奇,不知道是怎么實(shí)現(xiàn)的,后來仔細(xì)一想,應(yīng)該是整個啤酒罐是一張圖片(ImageView),該圖片是布局在三個按鈕之上,然后就是最關(guān)鍵的地方,把圖片設(shè)置為不可獲取焦點(diǎn),也就是Android:focusable="false" ,就這樣簡單的一行,就可以搞定了!

為了驗(yàn)證我的想法,我建了一個工程來做測試,效果如下圖所示:

具體代碼如下:

main.xml:

 
 
 
 
  1.    
  2.     android:layout_width="fill_parent"   
  3.     android:layout_height="fill_parent"   
  4.     >   
  5.     
  6.         android:layout_width="match_parent"   
  7.         android:layout_height="wrap_content"   
  8.         android:orientation="vertical" >   
  9.         
  10.             android:layout_width="match_parent"   
  11.             android:layout_height="wrap_content"   
  12.             android:layout_margin="10dp"   
  13.             android:text="button1"   
  14.             android:background="@drawable/button_selector"   
  15.             />      
  16.         
  17.             android:layout_width="match_parent"   
  18.             android:layout_height="wrap_content"   
  19.             android:layout_margin="10dp"   
  20.             android:text="button2"   
  21.             android:background="@drawable/button_selector"   
  22.             />    
  23.         
  24.             android:layout_width="match_parent"   
  25.             android:layout_height="wrap_content"   
  26.             android:layout_margin="10dp"   
  27.             android:text="button3"   
  28.             android:background="@drawable/button_selector"   
  29.             />    
  30.        
  31.     
  32.         android:layout_width="wrap_content"   
  33.         android:layout_height="wrap_content"   
  34.         android:src="@drawable/bg2"   
  35.         android:focusable="false"   
  36.         />   
  37.  

button_selector.xml:

 
 
 
 
  1.    
  2.     xmlns:android="http://schemas.android.com/apk/res/android">   
  3.        
  4.            
  5.                
  6.                
  7.                
  8.             
  9.                 android:width="2dp"   
  10.                 android:color="#FFFF00"/>   
  11.                
  12.             
  13.                 android:radius="5dp" />   
  14.             
  15.                 android:left="10dp"   
  16.                 android:top="10dp"   
  17.                 android:right="10dp"   
  18.                 android:bottom="10dp" />   
  19.            
  20.        
  21.  
  22.              
  23.            
  24.                
  25.                
  26.             
  27.                 android:radius="5dp" />   
  28.             
  29.                 android:left="10dp"   
  30.                 android:top="10dp"   
  31.                 android:right="10dp"   
  32.                 android:bottom="10dp" />   
  33.            
  34.        
  35.  

關(guān)于button_selector.xml中shape的使用有疑問的可以看我上次的文章:Android中shape的使用。

【編輯推薦】

Android ListView詳解

Android開發(fā)中插入新的Activity

在Android應(yīng)用程序中使用Internet數(shù)據(jù)


當(dāng)前標(biāo)題:Android中focusable屬性的妙用之底層按鈕的實(shí)現(xiàn)
本文URL:http://www.5511xx.com/article/dheohhd.html