本文實(shí)例講述了Android編程實(shí)現(xiàn)簡(jiǎn)單設(shè)置按鈕顏色的方法。分享給大家供大家參考,具體如下:
1.工程目錄
a.在res目錄-新建drawble文件夾放入自定義圖片

2.main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <ImageButton android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#000000" android:src="@drawable/sy" /></LinearLayout>
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); }}希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注