Android編程實現簡單設置按鈕顏色的方法
本文實例講述了Android編程實現簡單設置按鈕顏色的方法。分享給大家供大家參考,具體如下:
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);
}
}
更多關于Android相關內容感興趣的讀者可查看本站專題:《Android布局layout技巧總結》、《Android視圖View技巧總結》、《Android開發(fā)入門與進階教程》、《Android調試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結》及《Android控件用法總結》
希望本文所述對大家Android程序設計有所幫助。
- Android編程實現滑動按鈕功能詳解
- 自定義滑動按鈕為例圖文剖析Android自定義View繪制
- 如何在Android中實現漸顯按鈕的左右滑動效果
- Android中實現監(jiān)聽ScrollView滑動事件
- android中使用Activity實現監(jiān)聽手指上下左右滑動
- 如何在Android中實現左右滑動的指引效果
- Android中實現水平滑動(橫向滑動)ListView示例
- android 左右滑動+索引圖標實現方法與代碼
- Android仿今日頭條滑動頁面導航效果
- Android實現左右滑動效果的方法詳解
- Android基于ImageView繪制的開關按鈕效果示例
- Android按鈕單擊事件的四種常用寫法總結
- Android編程之滑動按鈕事件實例詳解
相關文章
Android中使用WebSocket實現群聊和消息推送功能(不使用WebView)
WebSocket protocol 是HTML5一種新的協(xié)議。它實現了瀏覽器與服務器全雙工通信(full-duplex)。本文給大家介紹Android中使用WebSocket實現群聊和消息推送功能(不使用WebView),需要的朋友參考下2016-02-02
Android GestureDetector手勢滑動使用實例講解
這篇文章主要為大家詳細介紹了Android GestureDetector手勢滑動使用實例,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-07-07
Android開發(fā)組件flutter的20個常用技巧示例總結
這篇文章主要為大家介紹了Android開發(fā)組件flutter的20個常用技巧示例總結,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-05-05

