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