Android pop-up activity setting method

Source: Internet
Author: User

How to set the Activity size so that your window will no longer look full screen. Some netizens may know how to implement Theme. Dialog Based on Theme, but tell everyone how to set Activity to no longer display in full screen. Android Theme is mainly implemented by defining styles. You can refer to the definition in Android Framework for Implementation Principles. Today, we provide a simpler but more flexible method, for example, do not use Theme. the border in Dialog. The following describes how to implement the custom Activity size.

1. Create a style file to your project and save it in res/values/styles. xml. Here the file name cannot be changed as needed, the content is, note that you use UTF-8 encoding when saving.

Java code

Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Resources>
<Style name = "Theme. Android123" parent = "android: style/Theme. Dialog">
<Item name = "android: windowBackground"> @ drawable/bg </item>
</Style>
</Resources>

2. the Theme style we defined above is Theme. android123, the parent style is still from Theme. dialog implementation, but we have customized the background in drawable/bg. Here we create a bg. put the xml file in the res/drawable folder, bg. the xml content is

Java code

Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Shape xmlns: Android = "http://schemas.android.com/apk/res/android">
<Padding android: left = "15dp" android: top = "15dp" android: right = "15dp" android: bottom = "15dp"/>
<Stroke android: width = "3dip" color = "#000000"/>
<Corners android: radius = "5dp"/>
<Solid android: color = "# ffffff"/>
</Shape>

We define a shape object to implement the background drawable shape. padding represents the distance border. Here we set the spacing between the left, top, right, and bottom positions. Stroke can produce some 3D effects. corners has four corners. The radius can be set for the radisu attribute. The larger the value, the smoother it is. You can fine-tune it according to the running effect. Finally, soild is the fill color, here we use ffffff to indicate pure white.

3. In androidmanifest. xml, add an android: theme attribute to your activity node with the value @ style/Theme. Android123.

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.