首页 > 代码库 > android之style使用demo
android之style使用demo
private void showDialog(){
final Dialog dialog = new Dialog(MainActivity.this, R.style.my_style);
dialog.setContentView(R.layout.help);
dialog.show();
ImageView imgView = (ImageView) dialog.findViewById(R.id.imageView_help);
imgView.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
dialog.dismiss();
}
});
}
help.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView_help"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/help" />
</LinearLayout>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestView</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<style name="my_style">
<item name="android:windowBackground">@color/back_color</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="darkgray">#808080</drawable>
<color name="back_color">#FF00FF</color>
<color name="top">#33CCFF</color>
<color name="top_background">#33CCFF</color>
</resources>
本文出自 “爬过山见过海” 博客,请务必保留此出处http://670176656.blog.51cto.com/4500575/1566766
android之style使用demo