本文實例講述了Android編程實現簡單設置按鈕顏色的方法。分享給大家供大家參考,具體如下:
1.工程目錄
a.在res目錄-新建drawble文件夾放入自定義圖片
2.main.xml
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:src="@drawable/sy"
/>
3.類代碼
package com.YANSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageButton;
public class YANSE extends Activity {
private ImageButton Image =null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Image=(ImageButton)findViewById(R.id.button);
}
}
希望本文所述對大家Android程序設計有所幫助。
總結
如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。
本圖文內容來源于網友網絡收集整理提供,作為學習參考使用,版權屬于原作者。
小編個人微信號 jb51ccc
喜歡與人分享編程技術與工作經驗,歡迎加入編程之家官方交流群!