Home  >  Q&A  >  body text

ui - Android Activity theme是作用于哪个View?

一个Activity声明如下:

<activity android:name=".MainActivity"
    android:theme="@android:style/Theme.Wallpaper.NoTitleBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

可以看到Activity的背景变成了桌面壁纸,其原理是将壁纸设置为了Activity中某个View的背景吗,如果是,怎么找到这个View,并获取这个壁纸实例(也就是这个壁纸)呢?

阿神阿神2763 days ago525

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:50:23

    getWindow().getDecorView();this

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:50:23

    Every activity needs setContentView. This View is.
    But this has nothing to do with theme. The theme acts on the Activity and does not directly affect the View

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:50:23

    The principle is not to set the wallpaper as the background of a certain View, create a simple Activity and then traverse upward to get this conclusion

    There is no detailed analysis of this principle after looking up some information. It is speculated that the wallpaper is displayed through a lower-level mechanism...
    If you find relevant analysis information, please share it, thank you :D

    reply
    0
  • Cancelreply