Does activity in Android have a window-like display similar to Windows programs?
The answer is of course there is.
is a window-type activity:
Let's talk about the implementation process:
First look at Androidmanifest.xml.
1: <?xml version= "1.0" encoding= "Utf-8"?>
2: <manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
3: package= "Com.hi.braincol.local"
4: android:versioncode= "1"
5: android:versionname= "1.0" >
6: <uses-sdk android:minsdkversion= "8"/>
8: <application android:icon= "@drawable/icon" android:label= "@string/app_name" >
9: <activity android:name= ". Miniactivity "
Ten: android:theme= "@style/translucent"
One: android:label= "@string/app_name" >
: <intent-filter>
: <action android:name= "Android.intent.action.MAIN"/>
: <category android:name= "Android.intent.category.LAUNCHER"/>
: </intent-filter>
: </activity>
: </application>
: </manifest>
Line 10th: android:theme= "@style/translucent" This is the key, as long as the style is set to a windowed, then miniactivity will be windowed. The following is the code for this style:
<?xml version= "1.0" encoding= "UTF-8"?>
<resources>
<style name= "Translucent" parent= "@android: Style/theme.translucent" >
<item name= "Android:windowbackground" > @drawable/panel_background</item>
<item name= "Android:windownotitle" >true</item>
<item name= "Android:windowisfloating" >true</item>
<item name= "Android:windowistranslucent" >true</item>
<item name= "Android:windowcontentoverlay" > @null </item>
<item name= "Android:windowanimationstyle" > @android:style/animation.dialog</item>
<item name= "android:backgrounddimenabled" >true</item>
</style>
</resources>
That's it, and it's easy to get it done.
Http://www.cnblogs.com/hibraincol/archive/2011/08/28/2156310.html
In the project, often need to use the dialog box effect, but the dialog box is not easy to write, so you want to write a translucent activity to replace the dialog box effect, the benefits of at least three:
One: Easy layout
Two: Various controls are easy to control
Three: Code concise: Do not write Control dialog box code in a lump, all kinds of control do not write in a lump, easy to maintain
And now in the online search for translucent activity, all need to write styles in style, color, and, of course, the final configuration in the mainfest, the result of a small translucent activity effect is very messy, and on the internet and so on that several methods , see the egg hurts, so in order to install force, I introduce a simple translucent activity effect:
Steps:
One: Write transparent colors in the root tag of the activity's layout:
Android:background= "#80000000"
Two: Configure the corresponding activity in the manifest file:
Android:theme= "@android: Style/theme.translucent.notitlebar"
OK, just these two steps,
The benefits of this effect are:
One: simple, just two lines of code
Second: Easy to modify, just two lines of code, just modify one place.
:
Detailed code:
One: layout:
[JavaScript]View Plaincopyprint?
- <?xml version="1.0" encoding="Utf-8"?>
- <relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"
- Android:layout_width="Match_parent"
- android:layout_height="Match_parent"
- android:background="#80000000" >
- <linearlayout
- Android:layout_width="Match_parent"
- android:layout_height="Wrap_content"
- android:layout_alignparentbottom="true"
- android:layout_marginbottom="40DP"
- android:layout_marginleft="18DP"
- android:layout_marginright="18DP"
- android:orientation="vertical" >
- <textview
- android:id="@+id/tv_delete"
- Android:layout_width="Match_parent"
- android:layout_height="Wrap_content"
- android:background="@drawable/rect_delete_red"
- android:gravity="center"
- android:paddingbottom="15DP"
- android:paddingtop="15DP"
- android:text="Delete"
- android:textcolor="#FFFFFF"
- android:textsize="20sp"/>
- <textview
- android:id="@+id/tv_cancel"
- Android:layout_width="Match_parent"
- android:layout_height="Wrap_content"
- android:layout_margintop="20DP"
- android:background="@drawable/rect_delete_gray"
- android:gravity="center"
- android:paddingbottom="15DP"
- android:paddingtop="15DP"
- android:text="Cancel"
- android:textcolor="#FFFFFF"
- android:textsize="20sp"/>
- </LinearLayout>
- </RelativeLayout>
Two: List file:
[JavaScript]View Plaincopyprint?
- <activity android:name="Com.itcode.DialogActivity"
- Android:theme="@android: Style/theme.translucent.notitlebar" ></activity>
http://blog.csdn.net/sunalongl/article/details/20544177