[英]how to set live wallpaper for background of layout,image view or … is that possible?
大家好,我想知道如何从Java设置动态壁纸的背景,图像视图或...这可能吗?如何? 选择一个动态壁纸,并设置为背景?我们可以用普通壁纸来做,但我不知道动态壁纸! 我尝试了很长时间的Google搜索。 我真的很需要知道。
这适用于普通Drawable:
File backgroundf = new File(Uri.parse("sdcar/Wallpaper_BG.jpg").getPath());
if (backgroundf != null) {
Bitmap BarbackgroundBitmap = BitmapFactory.decodeFile(backgroundf.getAbsolutePath());
BackgroundDrawable = new BitmapDrawable(mContext.getResources(), backgroundBitmap);
}
mBackground.setImageDrawable(BarBackgroundDrawable);
谢谢。
您不能将其作为可绘制背景或视图背景来进行,但是可以为活动设置主题以使墙纸或动态墙纸显示出来。
<style name="MyTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
您可以将任何主题用作父主题。 将其放在样式资源中,并为清单中的活动设置此主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.