Android編程實現(xiàn)簡單設(shè)置按鈕顏色的方法
本文實例講述了Android編程實現(xià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); } }
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android布局layout技巧總結(jié)》、《Android視圖View技巧總結(jié)》、《Android開發(fā)入門與進階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計有所幫助。
- Android編程實現(xiàn)滑動按鈕功能詳解
- 自定義滑動按鈕為例圖文剖析Android自定義View繪制
- 如何在Android中實現(xiàn)漸顯按鈕的左右滑動效果
- Android中實現(xiàn)監(jiān)聽ScrollView滑動事件
- android中使用Activity實現(xiàn)監(jiān)聽手指上下左右滑動
- 如何在Android中實現(xiàn)左右滑動的指引效果
- Android中實現(xiàn)水平滑動(橫向滑動)ListView示例
- android 左右滑動+索引圖標實現(xiàn)方法與代碼
- Android仿今日頭條滑動頁面導(dǎo)航效果
- Android實現(xiàn)左右滑動效果的方法詳解
- Android基于ImageView繪制的開關(guān)按鈕效果示例
- Android按鈕單擊事件的四種常用寫法總結(jié)
- Android編程之滑動按鈕事件實例詳解
相關(guān)文章
Android registerForActivityResult動態(tài)申請權(quán)限案例詳解
這篇文章主要介紹了Android registerForActivityResult動態(tài)申請權(quán)限案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-09-09Android?廣播接收器BroadcastReceiver詳解
Android開發(fā)的四大組件分別是:活動(activity),用于表現(xiàn)功能;服務(wù)(service),后臺運行服務(wù),不提供界面呈現(xiàn);廣播接受者(Broadcast Receive),勇于接收廣播;內(nèi)容提供者(Content Provider),支持多個應(yīng)用中存儲和讀取數(shù)據(jù),相當于數(shù)據(jù)庫,本篇著重介紹廣播組件2022-07-07Android通過json向MySQL中讀寫數(shù)據(jù)的方法詳解【讀取篇】
這篇文章主要介紹了Android通過json向MySQL中讀寫數(shù)據(jù)的方法,涉及Android解析json以及與php交互讀取mysql的方法,需要的朋友可以參考下2016-06-06