Original: http://blog.csdn.net/sodino/article/details/58221471.Activity Full transparency
Classmate Zzm gave this interesting code, which is now published.
First build the Colors.xml file under Res/values, write:
- <? XML Version = "1.0" encoding = "UTF-8" ?>
- < resources >
- < color name = "Transparent" > #9000 </ color > /c3>
- </ Resources >
This value sets the transparency of the entire interface, and is now set to about 56% (9/16) of the transparency to see the effect.
Then build Styles.xml under Res/values/, set the style of the program
- <?xml version= "1.0" encoding= "Utf-8"?>
- <resources>
- <style name= "Transparent" >
- <item name= "Android:windowbackground" > @color/transparent</item>
- <item name= "Android:windowistranslucent" >true</item>
- <item name= "Android:windowanimationstyle" >@+android:style/Animation.Translucent</item>
- </style>
- </resources>
The last step is to use this styles.xml in the corresponding activity. That is, add any <activity> tags in the androidmanifest.xml
- Android:theme = "@style/transparent"
If you want to set all the activity to use this style, you can add this tag statement in <application>.
Finally run the program, Haha, is not found that the entire interface is covered with a layer of translucent. Finally can change the background color #9000 to #0000, after running the program, it is completely transparent, see the background of all things can be invalid operation. Oh....
2.Dialog Full Transparency
1. Prepare a fully transparent material that retains the border, such as:
2. Create a new Styles.xml file in the values, which reads as follows:
- <?xml version= "1.0" encoding= "UTF-8"?>
<resources>
<style name= "Tancstyle" parent= "@android: Style/theme.dialog" >
<!--to replace the background image for full transparency--
<item name= "Android:windowbackground" > @drawable/panel_background_sodino1</item>
<!--screen background is not dimmed--
<item name= "android:backgrounddimenabled" >false</item>
<!--change dialog box title bar--
<item name= "Android:windowtitlestyle" > @style/titlestyle</item>
</style>
<style name= "TitleStyle" parent= "@android: Style/dialogwindowtitle" >
<item name= "Android:textappearance" > @style/titletext</item>
</style>
<style name= "TitleText" parent= "@android: Style/textappearance.dialogwindowtitle" >
<!--set the dialog title bar text color. -
<item name= "Android:textcolor" > #000 </item>
</style>
</resources>
3. Under the Layout folder, create a new file sentence as Main_dialog.xml, as follows:
[XHTML]View Plaincopy
- <? XML version= "1.0" encoding="UTF-8"?>
- <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="#0000">
- <ScrollView android:id="@+id/scrollview01"
- android:layout_width="wrap_content"
- android:layout_height="200px"
- android:layout_below="@+id/imageview01"
- android:background="#0000">
- <TextView android:id="@+id/textview01"
- android:text="Sodinotext"
- android:textcolor="#f000"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="#0000"
- ></TextView>
- </ScrollView>
- <button android:id="@+id/btncancel"
- android:layout_below="@id/scrollview01"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerhorizontal="true"
- android:text="Cancel">
- </Button>
- </relativelayout>
The 4.Activity code is as follows:
[XHTML]View Plaincopy
- Package Lab.sodino.tanc;
- Import android.app.Activity;
- Import Android.app.Dialog;
- Import Android.os.Bundle;
- Import Android.view.View;
- Import Android.widget.Button;
- Import Android.widget.TextView;
- public class Tancact extends Activity {
- /** called when the activity is first created. */
- @Override
- public void OnCreate (Bundle savedinstancestate) {
- Super.oncreate (savedinstancestate);
- Setcontentview (R.layout.main);
- Button btnshow = (button) Findviewbyid (r.id.btnshow);
- Btnshow.setonclicklistener (New Button.onclicklistener () {
- public void OnClick (view view) {
- Showtanc (
- "This is my custom dialog box",
- "Textcontent/nwhen a dialog is requested for the first time, Android calls Oncreatedialog (int.) from your Activity, which is where you should instantiate the Dialog. This callback method is passed the same ID, that's passed to ShowDialog (int). After you create the Dialog, return the object at the end of the method. ",
- "Http://blog.csdn.net/sodino");
- }
- });
- }
- private void Showtanc (string header, string content, string url) {
- Final Dialog Dialog = new Dialog (this, r.style.tancstyle);
- Dialog.setcontentview (R.layout.main_dialog);
- Dialog.settitle (header);
- Dialog.setcancelable (TRUE);
- TextView textView01 = (TextView) Dialog.findviewbyid (R.ID.TEXTVIEW01);
- Textview01.settext (content + content + content);
- Button btncancel = (button) Dialog.findviewbyid (R.id.btncancel);
- Btncancel.setonclicklistener (New Button.onclicklistener () {
- public void OnClick (view view) {
- Dialog.cancel ();
- }
- });
- Dialog.show ();
- }
- }
At last:
Additional Android system comes with icon Daquan (1.5 1.6 2.1)
http://since2006.com/android/1.5-drawables.php