android-Optimizing UI Performance (3)-Optimize your activity's background image
At some point, we may want to improve the performance of the activity as much as possible, then we can optimize the activity's background graph
First, in the activity, not only the view that you use for the Setcontentview (), but also some other view
Such as:
By default, Decorview contains a default background map, which is the starting point to optimize activity
1, using
GetWindow (). setbackgrounddrawable (drawable)
GetWindow (). Setbackgrounddrawableresource (Resid)
The code is as follows:
@Override protectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setBackgroundDrawableResource(R.drawable.ic_launcher); setContentView(R.layout.activity_main); }
2, custom theme
Create a Res/values/theme.xml file
The format is defined as follows:
<resource> <style name="Mytheme" parent="android:Theme"> <item name="android:windowBackground">@null</item> </style></resources>
You can set the mytheme to NULL as needed or the background image you need
Then add it in the OR tag
android:theme="@style/MyTheme"
Copyright NOTICE: Welcome to communicate the error of the article, must humbly accept, QQ872785786
Android-Optimizing UI Performance (3)-Optimize your activity's background image