How to set the size of the activity so that your window does not look full-screen. Some netizens may know how to do this through themes such as theme.dialog, but tell everyone to set the principle that the activity will not be displayed in full screen. The Android theme is also largely done by defining style, and the principle of implementation is that you can look directly at the definition in the Android framework and give a simpler, but relatively flexible, approach today For example, do not theme.dialog in the border, below together to see the implementation of the custom activity size.
1. Create a style file to your project, save in Res/values/styles.xml, where the filename can not be arbitrarily modified, the content is, note that the use of UTF-8 encoding when saving.
Java code
Copy Code code 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. Above we define the theme style for theme.android123, the parent style is still implemented from the Theme.dialog, but we customize the background, location in DRAWABLE/BG, where we create a bg.xml file into res/ In the Drawable folder, the contents of the Bg.xml are
Java code
Copy Code code 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>
Inside we define a Shape object that implements the background drawable shape, where the padding represents the distance border, where we set the spacing of the left, top, right, and bottom four positions. Stroke can produce some 3D stereo effect, corners is Four Corners, Radisu properties can set the radius, the greater the value of the more smooth, according to the operation of the effect you can fine-tune, the last soild is filled with color, here we use the FFFFFF to express pure white.
3. Finally in Androidmanifest.xml, add a android:theme attribute to your Activity node, and the value is @style/theme.android123