In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the basic knowledge of Android and the example analysis of linear layout, which is very detailed and has a certain reference value. Friends who are interested must finish it!
1. Basic properties of common controls
Android:id= "@ + id/button1": [set control id]
Android:layout_width [set Control width] / android:layout_height [set Control height]
Wrap_content [the size of the control is determined internally]
Match_parent [the control is the same size as the parent control]
Android:text= "": [set component text]
Android:textColor= "": [set font color]
Android:layout_marginLeft: [distance between the current layout and the left edge of the parent layout]
Android:layout_marginRight: [distance between the current layout and the right edge of the parent layout]
Android:layout_marginTop: [distance between the current layout and the top edge of the parent layout]
Android:layout_marginBottom: [distance between the current layout and the bottom edge of the parent layout]
Android:gravity: [the location of the contents of view in this view]
Android:layout_gravity: [the position of this view relative to its parent view]
1. Gravity does not play any role in linear layout, while layout_gravity plays a role in linear layout.
2. When we use android:orientation= "vertical", android:layout_gravity works only if it is set horizontally.
The vertical setting does not work. That is, left,right,center_horizontal is effective.
3. When we use android:orientation= "horizontal", only the vertical setting of android:layout_gravity works
The horizontal setting does not work. That is, top,bottom,center_vertical is effective.
1.1 visibility of the control
This property has three state values: gone, visible, and invisible.
The differences between gone and invisible are:
Gone indicates that the control is not visible, will not occupy any place, and will not respond.
Invisible means that although the control is not visible, it will occupy its width and height.
Example:
The effect is as shown in the figure:
Example:
The effect is as shown in the figure:
1.2 the outer margin of the control
Anyone who has studied HTML will know that the box pattern in CSS has an outer margin and an inner margin.
The outer margin sets the distance of the view from the top and bottom of the parent view.
The inner margin sets the distance from the inside of the view to the top and bottom of its own border.
The control layout of Android actually uses this box mode.
If the outer margin is the same from the top and bottom of the parent view, you can set it like this:
Android:layout_margin= "10dp"
We can also set an outer margin separately:
The inner margin of android:layout_marginTop= "10dp" android:layout_marginBottom= "10dp" android:layout_marginLeft= "10dp" android:layout_marginRight= "10dp" 1.3controls
Set the upper and lower left and right inner margins uniformly:
Android:padding= "5dp"
Set the inner margin individually:
Android:paddingTop= "5dp" android:paddingBottom= "5dp" android:paddingLeft= "5dp" android:paddingRight= "5dp" 2. Linear layout (Linear Layout)
LinearLayout core attributes:
(1) android:orientation: two attribute values: "vertical" vertical "horizontal" horizontal
(2) android:layout_weight redistributes the remaining space of the parent control according to the set weight ratio.
2.1 example:
2.2 actual combat of Wechat interface
The above is all the contents of the article "sample Analysis of Android Basics and Linear layout". Thank you for reading! Hope to share the content to help you, more related knowledge, 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: 288
*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.