setTheme问题2
16lz
2021-01-24
在xml 设置的效果
和setTheme的效果不一样
android:windowBackground
没有效果????????
代码如下:
super.onCreate(savedInstanceState); setTheme(R.style.blueSummerTheme); setContentView(R.layout.main);
解决方案!!
有效果的代码!
setTheme(R.style.blueSummerTheme); super.onCreate(savedInstanceState); setContentView(R.layout.main);
内部原理的分析:
主题设置要先获取相关属性的设置,在进行绘制在界面上!
from 下面这句话便可以得出这样的结论!
public void setTheme(int resid)
Since: API Level 1Set the base theme for this context. Note that this should be called before any views are instantiated in the Context (for example before calling setContentView(View)
or inflate(int, ViewGroup)
).
Parameters
resid | The style resource describing the theme. |
---|
上面的android:windowBackground没有效果,是因为它的属性的获取是在
super.onCreate(savedInstanceState);
故要 把它放在 setTheme的后面便会有效果!
呵呵!下班了!
更多相关文章
- android 源码大全
- Android加载网络图片
- Android(安卓)Intent Flag组合使用
- Android(安卓)Studio 配置多个代码仓库(maven)
- android -------- ConstraintLayout 宽高比和偏移量比(三)
- android设置wallpaper
- Android(安卓)CollapsingToolbarLayout:将ActionBar载入Toolbar(2)
- Android(安卓)为Notification加上一个进度条
- 第一篇 GridView控件