gpt4 book ai didi

Android:为RelativeLayout设置背景图片?

转载 作者:可可西里 更新时间:2023-11-01 18:43:55 25 4
gpt4 key购买 nike

我在运行时下载了一张图片。现在我想将它设置为 RelativeLayout 的背景。可能吗?

最佳答案

查看 setBackgroundDrawable ,或者可能是 createFromPath在 Drawable 类中。

   RelativeLayout rLayout = (RelativeLayout) findViewById (R.id.rLayout);
Resources res = getResources(); //resource handle
Drawable drawable = res.getDrawable(R.drawable.newImage); //new Image that was added to the res folder

rLayout.setBackground(drawable);

关于Android:为RelativeLayout设置背景图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4906422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com