亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

調整按鈕上的背景圖像大小

調整按鈕上的背景圖像大小

叮當貓咪 2023-04-19 16:38:53
當我點擊按鈕時,我想要一個按鈕上的背景圖像。為此我使用了以下方法。Button button=findViewById(R.id.button_00); button.setBackgroundResource(R.drawable.jerry);當我點擊按鈕時背景圖像確實出現了。但是圖像比按鈕大。告訴我如何解決這個問題。
查看完整描述

1 回答

?
慕后森

TA貢獻1802條經驗 獲得超5個贊

很好,您將 Buttons 更改為 ImageButtons 并使用android:src代替android:background例如:


<ImageButton

android:id="@+id/button_00"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/jerry"

android:onClick="btn_click" />

您也可以設置圖像運行時


ImageButton button=findViewById(R.id.button_00);

button.setImageResource(R.drawable.jerry);


查看完整回答
反對 回復 2023-04-19
  • 1 回答
  • 0 關注
  • 202 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號