第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如下程序,有人知道是怎么回事嗎?

如下程序,有人知道是怎么回事嗎?

嗶嗶one 2022-10-07 19:15:46
@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉標(biāo)題欄setContentView(R.layout.wk_main);/*這里背景圖片設(shè)置成功了*/layout=(LinearLayout) findViewById(R.id.layout1);resources = getResources();btnDrawable = resources.getDrawable(R.drawable.app2_0);layout.setBackgroundDrawable(btnDrawable);/*到這里 就設(shè)置失敗*/btnDrawable = resources.getDrawable(R.drawable.app1_1);layout.setBackgroundDrawable(btnDrawable);<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/layout1"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="match_parent"android:orientation="horizontal"android:layout_weight="1">
查看完整描述

2 回答

?
飲歌長嘯

TA貢獻(xiàn)1951條經(jīng)驗(yàn) 獲得超3個(gè)贊

教你如何設(shè)置背景圖片
xml文件設(shè)置背景圖片中:
任意一個(gè)控件,button imageView 或layout,在其的xml屬性設(shè)置中,添加

[java] view plaincopy
android:background="@drawable/bg"

即可實(shí)現(xiàn)設(shè)置其背景圖片為bg.
其中bg.bnp圖片存放在drawable目錄下。
drawable目錄下存放大小圖標(biāo)共用的圖片。drawable-hdpi中存放240 WVGA800 的模擬器或板子用的圖片。drawable-mdpi存放對應(yīng)的小圖片

[java] view plaincopy
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pic"/>

同樣,用src屬性,也可設(shè)置imageView的圖片為pic.png

java代碼中設(shè)置或更改一個(gè)控件的背景圖片:

[java] view plaincopy
Resources resources = getContext().getResources();
Drawable btnDrawable = resources.getDrawable(R.drawable.layout_bg);
layout.setBackgroundDrawable(btnDrawable);

程序中,動(dòng)態(tài)修改layout的背景圖片,用setBackgroundDrawable()函數(shù)實(shí)現(xiàn)。設(shè)置其背景圖片為 layout_bg.png

修改imageView1的背景圖片為imageView2的背景圖片:
imageView2.getDrawable()可獲得圖片2的背景。值為Drawable類型
imageView1.setImageDrawable(drawable); 設(shè)置imageView1的背景圖片

即:

[java] view plaincopy
imageView1.setImageDrawable(imageView2.getDrawable());


查看完整回答
反對 回復(fù) 2022-10-12
?
MYYA

TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個(gè)贊

代碼如下:
LinearLayout?temp=(LinearLayout)findViewById(R.id.LinearLayout的id);
Drawable?d=Drawable.createFromPath(圖片路徑);
temp.setBackgroundDrawable(d);

查看完整回答
反對 回復(fù) 2022-10-12
  • 2 回答
  • 0 關(guān)注
  • 122 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號