當前位置:首頁 » 高清圖片 » 安卓背景圖片
擴展閱讀
女生和渣男搞笑圖片 2023-08-31 22:07:09
嘻嘻長什麼樣圖片 2023-08-31 22:06:10

安卓背景圖片

發布時間: 2022-02-14 05:26:07

Ⅰ android設置背景圖片

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

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

即可實現設置其背景圖片為bg.
其中bg.bnp圖片存放在drawable目錄下。
drawable目錄下存放大小圖標共用的圖片。drawable-hdpi中存放240 WVGA800 的模擬器或板子用的圖片。drawable-mdpi存放對應的小圖片

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

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

java代碼中設置或更改一個控制項的背景圖片:

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

程序中,動態修改layout的背景圖片,用setBackgroundDrawable()函數實現。設置其背景圖片為 layout_bg.png

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

即:

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

Ⅱ 在android編程中怎麼插入背景圖片啊

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/qq"
>
上面的代碼是把drawable下的名字為qq的圖片作為背景

Ⅲ android怎麼設置自適應大小的背景圖片

需要給你的ImageView布局加上Android:adjustViewBounds="true"

<ImageView android:id="@+id/test_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_launcher" />

然後,在代碼里設置ImageView.最大寬度和最大高度,因為adjustViewBounds屬性只有在設置了最大高度和最大寬度後才會起作用

int screenWidth = getScreenWidth(this);
ViewGroup.LayoutParams lp = testImage.getLayoutParams();
lp.width = screenWidth;
lp.height = LayoutParams.WRAP_CONTENT;
testImage.setLayoutParams(lp);

testImage.setMaxWidth(screenWidth);
testImage.setMaxHeight(screenWidth * 5); 這里其實可以根據需求而定,我這里測試為最大寬度的5倍

Ⅳ Android app中如何設置背景圖片

是因為你把這個圖片放在了drawable-land文件夾下,你放到drawable-hdpi下試試看。

Ⅳ 安卓手機壁紙在哪個文件夾

你們好像都答非所問。
他問的是用一張相片做壁紙,現在相片刪除了,壁紙還在,想在手機的系統文件里找出這張壁紙圖片。就好像xp設置壁紙後該圖片會被復制到c:\windows\web\wallpaper這里。但是安卓的就不知道放在哪裡,我自己找過也沒找到。

Ⅵ 安卓--如何用圖片鋪滿屏幕(即做成背景)

意義不明
如果只是全屏鋪滿,你弄一個ImageView
設置ScaleType為fitCenter就可以了
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/a5game_fruit_holiday_yd"
android:scaleType="fitCenter"/>

Ⅶ android動態背景圖片改變

Button setIcon;
boolean isIconChange = true;
//-----------------------------------------------
setIcon.setBackgroundResource(R.drawable.bg1); //setIcon定義為全局
isIconChange = false;//定義為全局
setIcon.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

if(isIconChange){
setIcon.setBackgroundResource(R.drawable.bg1);
isIconChange = false;
}else{
setIcon.setBackgroundResource(R.drawable.bg2);
isIconChange = true;
}
}
});

就行了 ,不用放在xml裡面。

Ⅷ Android設置背景圖片和背景色

你應該是寫android的 你應該知道layout的存在吧,你可以設置兩個layout一個是全背景,然後用setbackgroundclolr(blue)方法設定背景顏色,然後在其內部設置一個小的layout這個layout你自己設定大小,然後用setbackgroundresouce(xxx)把你的圖片放到上面就可以了,簡單的說就多了一個layout而已,希望能幫到你。

Ⅸ 安卓加背景圖片就報錯 求大神看看

你的那個圖片太大了,內存溢出了。換個小點的。

Ⅹ 安卓手機背景圖片顯示不全,怎麼辦

修改圖片尺寸後可以完整顯示。

  1. 網路搜索對應手機壁紙的尺寸。

  2. 在Photoshop中新建一個空白的文檔,尺寸為搜索到的尺寸。

  3. 導入需要作為手機壁紙的圖片,進行拉伸處理。

  4. 提醒:如果圖片縮小後寬度不夠尺寸要求,可以讓需要顯示的圖片在Photoshop里居中,兩側用同一張圖片覆蓋。

  5. 保存後導入手機,在壁紙設置中選擇居中,這樣就不會被拉伸變形,也能完整顯示了。