Android custom window size settings, android pop-up activity settings method

How to set the size of the Activity so that the window is no longer displayed in full screen, and Android themes are mainly implemented by defining styles. The implementation principle can be directly seen in the definition of the Android framework. Today, the Love Station Technology Channel gives a simple but relatively flexible method. , let's follow the steps of Xiaobian to find out!

1. Create a style file to your project and save it in res/values/styles.xml, where the file name cannot be modified casually, the content is, pay attention to use UTF-8 encoding when saving.

Java code

Copy the code The code is as follows:

2. The theme style we defined above is Theme.Android123, the parent style is still implemented from Theme.Dialog, but we customize the background, the location is in drawable/bg, here we create a bg.xml file and put it in the res/drawable file folder, the content of bg.xml is

Java code

Copy the code The code is as follows:

Inside we define a shape object to implement the background drawable shape, where padding represents the distance border, here we set the spacing of the left, upper, right and lower positions. Stroke can create some 3D three-dimensional effects. Corners are four corners. The radius attribute can set the radius. The larger the value, the smoother it will be. You can fine-tune it according to the running effect. Finally, the soild is the fill color. Here we use ffffff to represent pure white.

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

Through the method of setting the size of the android pop-up activity introduced by the editor of the love station technology channel, I believe everyone has a certain understanding. If you want to know more relevant information, please continue to pay attention to the love station technology channel!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324151033&siteId=291194637