Android dynamic skin replacement, the Android system has solved the skin Replacement problem perfectly, and many friends on the Internet are still asking how to skin replacement. Let's take a look at the Android skin change. After clicking the theme skin after Day, click Night, and the theme skin [java] package cn. hpc. assistant; import android. app. activity; import android. content. context; import android. graphics. pixelFormat; import android. graphics. point; import android. OS. bundle; import android. OS. handler; import android. OS. message; import android. view. gravity; import android. view. view; import android. view. windowManager; import android. view. W IndowManager. layoutParams; public class MainActivity extends Activity {private int mThemeId =-1; // skin topic ID. The default value is-1, which is not processed @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); if (savedInstanceState! = Null) {if (savedInstanceState. getInt ("theme",-1 )! =-1) {// read the skin topic ID.-1 does not process the memeid = savedInstanceState. getInt ("theme"); this. setTheme (mThemeId); // set the topic skin} setContentView (R. layout. activity_main); this. findViewById (R. id. id_btn_day ). setOnClickListener (mOnClickListener); // bright theme this. findViewById (R. id. id_btn_night ). setOnClickListener (mOnClickListener); // night dark theme} View. onClickListener mOnClickListener = new View. onClickListener () {@ Override public void onClick (View v) {// TODO Auto-generated method stub switch (v. getId () {case R. id. id_btn_day: onTheme (android. r. style. theme_Light); break; case R. id. id_btn_night: onTheme (android. r. style. theme_Black); break; default :}}; // set the topic and create private void onTheme (int iThemeId) {mThemeId = iThemeId; this. recreate ();} // Save the topic ID. When onCreate is used, the topic @ Override public void onSaveInstanceState (Bundle outState) {super. onSaveInstanceState (outState); outState. putInt ("theme", mThemeId);} layout file: activity_main.xml [html] <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: orientation = "horizontal" tools: context = ". mainActivity "> <TextView android: layout_width =" wrap_content "android: layout_height =" wrap_content "android: layout_centerHorizontal =" true "android: layout_centerVertical =" true "android: text = "@ string/hello_world"/> <Button android: id = "@ + id/id_btn_fun" android: layout_width = "wrap_content" android: layout_height = "wrap_content"/> <Button android: id = "@ + id/id_btn_day" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "Day"/> <Button android: id = "@ + id/id_btn_night" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "Night"/> </LinearLayout>