AppCompat 相当于 "Theme.Wallpaper.NoTitleBar.Fullscreen"
AppCompat equivalent to "Theme.Wallpaper.NoTitleBar.Fullscreen"
我正在努力创建一个自定义启动器,发现这个很棒tutorial
只要我用 Activity 扩展我的活动,一切都很好。我想使用 AppCompatActivity 扩展我的活动,但在这样做时,我收到以下错误:
You need to use a Theme.AppCompat theme (or descendant) with this activity
所以我决定写自己的风格:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/AppTheme">
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
这似乎可以解决问题,但是我的背景不再设置为 phone 的墙纸。相反,它是白色的。
我想要的:
我得到的:
我感谢所有可能解决我的问题或让我走上解决问题的正确道路的技巧和提示。提前致谢。
试试这个:
在 onCreate() 中:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
RelativeLayout ll = (RelativeLayout) findViewById(R.id.main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ll.setBackground(wallpaperDrawable);
}
其中 main 是 activity 的根布局的 ID。
我正在努力创建一个自定义启动器,发现这个很棒tutorial
只要我用 Activity 扩展我的活动,一切都很好。我想使用 AppCompatActivity 扩展我的活动,但在这样做时,我收到以下错误:
You need to use a Theme.AppCompat theme (or descendant) with this activity
所以我决定写自己的风格:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/AppTheme">
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
这似乎可以解决问题,但是我的背景不再设置为 phone 的墙纸。相反,它是白色的。
我想要的:
我得到的:
我感谢所有可能解决我的问题或让我走上解决问题的正确道路的技巧和提示。提前致谢。
试试这个:
在 onCreate() 中:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
RelativeLayout ll = (RelativeLayout) findViewById(R.id.main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ll.setBackground(wallpaperDrawable);
}
其中 main 是 activity 的根布局的 ID。