In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article "Android top title bar layout design method is what" most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "Android top title bar layout design method is what" article it.
Customize the title block
Usually our activity page will have different title bars to choose according to the needs, there are generally two scenarios, one is a unified title bar, which can be reused by introducing layout into activities, and another is that each of your activity pages need to be customized, so you can't unify the style.
Layout and Nine Palace Grid background Picture
Let's talk about some collocation between the layout and the Nine Palace grid.
Overall Arrangement
The layout of the commonly used design title bar is carried out through streaming layout. Why? Do you think that sometimes streaming layout is a little more troublesome? Title blocks generally have control dependencies. Why not use the relative layout? Isn't the relative layout for solving dependencies? Yes, but there is a little design trick. The relative layout does have a good applicability to the dependency relationship. But take into account changes in project requirements. When you first designed it, you probably thought it was in the right position. But now that the requirements have changed, if some controls need to be changed, do you find it troublesome? adding or deleting may disrupt all your layout, and you need to reassign dependencies.
So how does streaming layout accomplish dependencies? We can add a view to separate him. Through the distribution of weights, we can also achieve the effect of relative layout. It can be split with a view of 0.1dp height.
Of course, this is not absolute, it does not mean that it is better to use streaming, compared to the title bar of most scenes, it is relatively simple to display, so using streaming is also possible. But if, ah, if the controls of your title bar are to be placed horizontally and vertically, in this case, if you still want to use streaming layout, you need to do layout nesting, which will increase the cost. If this is the case, I may think the relative layout is better.
Is it because of the dependencies of controls that you don't want to use relative layouts? In fact, the most appropriate place to use relative layout is not the dependency of relative controls (a wide range of specified controls), but the dependency of relative layout. This is even more useful. Usually our page will also have scrolling scenes of list classes such as listview, and there will also be scenarios of using the system soft keyboard for input. If we do not specify the dependency between layouts and use streaming layout of these, you will find that when you click on the input box to pop up the keyboard, the bottom of your page will be topped by the keyboard, and the page controls will not be fully displayed, which is because the height has changed. Of course, you can also customize the listening events, detect the height, and then do logical processing.
Summary: when designing the layout, the relative layout is equivalent to the parent layout as far as possible. Small dependencies are solved by streaming layout as much as possible, similar to a simple title bar for later maintenance.
Nine Miyagi pictures
Then after talking about the layout, what does it have to do with the photos of the ninth palace grid?
Let's talk about the picture of Jiugong grid first. friends who know can skip it.
The first is its origin. Technological progress has always been based on demand. Having this thing means that there is something wrong with it. So what's the problem?
When we set a picture as the background of the view, if the size of the picture is too small, the system will automatically stretch the picture to fill the background. Once the picture is pulled too large, the picture will easily become blurred. In order to solve this problem, Android designed this point nine picture. Its extension is png, and the file name is often followed by the word ".9". The picture is divided into 3-by-3 areas. If the background is a shape shape and the width property of its stroke node has been set to a fixed value (such as) 1dp, then no matter how much the shape stretches, the stroke width is always 1dp. The implementation principle of the point 9 picture is similar, that is, when stretching the shape, only the inner area is stretched, not the edge lines.
Here is a background picture of the Jiugong grid:
On the left is the processing area, and on the right is the picture preview area, which is stretched longitudinally, horizontally and in both directions from top to next. Click on the mosaic around the picture in the left window and a black dot will appear. Drag the black dot left or right or up and down a black line, and the black lines in different directions will show different effects.
The left black line refers to the stretch area in the vertical direction. When stretching the picture vertically, only the image in the area of the black line will be stretched, and the area that is not in the black line will not stretch and remain as it is, so as to ensure that the thickness of the frame on the upper and lower sides remains the same.
The upper black line refers to the stretch area in the horizontal direction. It's the same as above. Stretch horizontally, stretch inside the black line, and not stretch outside the black line.
The lower black line means that when the picture is used as the background of the control, the left and right boundaries of the text inside the control can only be placed in the black line area. As pictured above. In this way, you will automatically have the effects of android:paddingLeft and android:paddingRight. It's the equivalent of automatically adding it for you.
The black line on the right is the same as above. It's just different. This is equivalent to the upper and lower boundary in the black line. It is also equivalent to automatically adding android:paddingTop and android:paddingBottom.
Does that match our layout very well? we usually need to set a color for things like the title bar, then the nine-grid picture can help you very well, through simple black lines, you can reduce some of the code to set the upper and lower left and right boundaries, don't you think it's easier?
It is also important to note that if the Nine Palace grid picture is set as the view background, and Horizontal Padding and Vertical Padding are specified, then the interior of the view will always maintain a fixed distance with the edge of the view, no matter how to adjust the xml file and java code. Because it is the padding set by the picture of Nine Miyagi.
We can also set some state list background for the internal control to change, so that when we click on the control or get focus, there is an obvious effect.
The above is about the content of this article on "what is the layout design method of the top title bar of Android". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to 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.