Android 開發筆記___drawable

來源:互聯網
上載者:User

標籤:ttext   raw   schema   checked   XML   src   item   extc   預設   

 

 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" 5     android:orientation="vertical"> 6  7     <Button 8         android:layout_width="wrap_content" 9         android:layout_height="wrap_content"10         android:layout_gravity="center"11         android:layout_margin="10dp"12         android:text="預設樣式的按鈕"13         android:textColor="#000000"14         android:textSize="17sp" />15 16     <Button17         android:layout_width="wrap_content"18         android:layout_height="wrap_content"19         android:layout_gravity="center"20         android:layout_margin="10dp"21         android:paddingLeft="8dp"22         android:paddingRight="8dp"23         android:background="@drawable/btn_nine_selector"24         android:text="定製樣式的按鈕"25         android:textColor="#000000"26         android:textSize="17sp" />27 28 </LinearLayout>

selector

1 <?xml version="1.0" encoding="utf-8"?>2 <selector xmlns:android="http://schemas.android.com/apk/res/android">3     <item android:state_pressed="true" android:drawable="@drawable/button_pressed" />4     <item android:drawable="@drawable/button_normal" />5 </selector>

java

 1 package com.example.alimjan.hello_world; 2  3 import android.app.Activity; 4 import android.content.Context; 5 import android.content.Intent; 6 import android.os.Bundle; 7 import android.support.annotation.Nullable; 8  9 /**10  * Created by alimjan on 7/1/2017.11  */12 13 public class class__2_4_1_1  extends Activity {14     @Override15     protected void onCreate(@Nullable Bundle savedInstanceState) {16         super.onCreate(savedInstanceState);17         setContentView(R.layout.code_2_4_1_1);18     }19     public static void startHome(Context mContext) {20         Intent intent = new Intent(mContext, class__2_4_1_1.class);21         mContext.startActivity(intent);22     }23 }
狀態類型 說明 常用的控制項
state_pressed 是否按下 按鈕button
state_checked 是否勾選 單選框RadioButton、複選框chenckBox
state_focused 是否擷取焦點 文本編輯框Edittext
state_selected 是否選中

各控制項均可

Android 開發筆記___drawable

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.