Android implements the method of setting an activity as a window style _android

Source: Internet
Author: User

The example in this article describes how the Android implementation sets an activity to a window style. Share to everyone for your reference, specific as follows:

1. Add the following code to the Style.xml file in the Res/value folder:

<style name= "theme.floatactivity" parent= "Android:style/theme.dialog" >
  <!--float_box for us to define the window background, This is not necessary.-->
  <item name= "Android:windowbackground" > @drawable/float_box</item>
</style >

2. Under the Res/drawable folder, create a new Float_box.xml file with the following code:

<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
  <solid android:color=" #ffffff "/>
  <stroke android:width=" 3DP "android:color=" # ff000000 "/>
  <corners android:radius=" 3DP "/> <padding android:left=
  " 10DP "android:top=" 10DP " android:right= "10DP" android:bottom= "10DP"/>
</shape>

3. In the statement of activity in Androidmainifest.xml, add

Android:theme= "@style/theme.floatactivity"

The effect is as follows:

More interested readers of Android-related content can view this site: "Introduction to Android Development and advanced Course", "Android Service Component Usage Summary", "Android Basic component Usage Summary" and "Android Control usage Summary"

I hope this article will help you with the Android program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.