In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of how to achieve adaptive layout in Android, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this Android article on how to achieve adaptive layout. Let's take a look at it.
Res/values/styles.xml
0dp 16dp match_parent match_parent vertical @ drawable/container_background
For a flat panel (vertical), we can add some margins because the screen is big enough.
Res/values-sw600dp/styles.xml
0dp 32dp match_parent match_parent vertical @ drawable/container_background
The difference between vertical and horizontal on the tablet is that we add a margin value so that the content does not fill the entire screen, and we can add a background image to the parent view to fill the blank area.
Res/values-sw600dp-land/styles.xml
130dp 130dp 32dp match_parent match_parent vertical @ drawable/container_background
Then we can use the style file on different screens:
... Buttons, edit texts, text views, etc...
This is the effect of a phone on a four-inch screen:
This is the effect on a seven-inch tablet:
This is the horizontal screen effect of the seven-inch flat panel:
There are also some properties that are very convenient in CSS (such as bootstrap), which are helper classes, such as. Visible-phone,.hidden-phone,.visible-tablet, and so on, which can also be done on Android.
Gone visible gone visible
Put these styles in the corresponding configuration folder, and then you can hide and display the corresponding controls when needed.
... Some content...... Some extra content since we have space...
For flat panels (horizontal), this style displays two columns, but for most devices, the second column is not displayed.
With just a few lines of xml code, we can create a mini layout framework, and we can extend this technique to implement a general style file as needed, which can be used in the project later.
This is the end of the article on "how to achieve adaptive layout in Android". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to achieve adaptive layout in Android". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.