I want to set my app's background to be the same as my home screen's wallpaper. How can I get the home screen wallpaper in activity.xml? Can I do that?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Use
to get the current wallpaper. Then set it as your own app's background:
All this should happen in the onCreate() if you wish to have it as the initial background.
While @Robin's answer does set the Activity's background to the home screen's wallpaper, it displays the whole drawable at once, which in most cases distorts it (horizontally compresses it).
A different solution, which may be better or worse depending on your precise needs, is to set your Activity's theme to one that inherits from
Theme.Wallpaper
. I find this somewhat easier, and the system automatically shows you an appropriate slice of the wallpaper, which is what I want and expect.res/styles.xml:
AndroidManifest.xml: