安卓學習第6課——button

來源:互聯網
上載者:User

標籤:android   style   blog   http   color   檔案   

今天學會了按鈕的背景圖片是可以改變的。。。

背景可以不是圖片,而是一個xml檔案。

<Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="帶文字的圖片按鈕"         android:background="@drawable/button_selector"        android:textSize="10pt"       />

button_selector

<?xml version="1.0" encoding="UTF-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <!-- 指定按鈕按鈕下時的圖片 -->    <item android:state_pressed="true"        android:drawable="@drawable/red"    />    <!-- 指定按鈕鬆開時的圖片 -->        <item android:state_pressed="false"        android:drawable="@drawable/purple"    /></selector>

可以顯示一個按鈕點擊過程有紫變紅過程,我覺得這就可以解釋有很多都是點擊會變色。。。感覺很好看。。

按鈕還可以顯示陰影也是一種特效

    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="文字帶陰影的按鈕"        android:textSize="12pt"        android:shadowColor="#aa5"        android:shadowDx="5"        android:shadowDy="5"        android:shadowRadius="1" />

這個會顯示字型有陰影的按鈕。。。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.