In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you to the Android interface design foundation in the control focus of what is the step, the content is very detailed, interested friends can refer to, I hope to help you.
Android devices have a variety of operating interfaces, such as touch screens, trackballs, traditional mobile phone keyboards, etc., so developers need to better understand the order in which each control gains focus and loses focus when the user moves between different controls in the application interface, and how to customize these orders according to the user's operating habits.
In general, Android will automatically arrive at an appropriate control focus order for a particular layout interface, which is sufficient in many cases. But there are exceptions in some cases. Control the next focus will reach which control, mainly to determine the current control in the specified direction layout (up/down/left/right), which is the closest control, the scanning order is from left to right, from top to bottom, just like reading books.
However, this order sometimes causes a small problem, such as when the controls are arranged at the top of the screen, if the user presses the "up" key again, there will be no effect, and similarly, when the controls are arranged at the bottom, left, and right of the screen, pressing the "down","Left", and "Right" keys will no longer gain focus on the controls.
In the example in this article, you will see how to modify the default control focus order to customize a specific control switching order. In the example, multiple buttons are arranged in a circle. Examples can be found in
http://android-mt-tutorials.googlecode.com/svn/trunk/SimpleFocus
Step 1 Define the interface layout
We first design the layout of the interface, the code is as follows, using the Relative relative layout:
The style file defined above is as follows:
38dp 38dp numClicked 9sp
After running, the effect is as follows:
Step 2 Default Control Focus Switching Order
For example, when the user puts the control focus point on button 12, click the "down" button, and the default control focus switching sequence is as follows:
That is, when pressed down on button 12, the focus of the control switches to 11, followed by key 10, and so on.
Step 3 Create a custom control focus order
Below, we try to create a custom control focus order, that is, at the same time allow in the above interface, when the user presses the key, the control switches clockwise or counterclockwise, as shown below:
That is, the user is allowed to switch clockwise when pressing the "Down" or "Right" key, for example, if he is currently on key 12, pressing the "Down" or "Right" key will switch to key 1, pressing the "Up" or "Left" key will switch to key 11, and so on. To do this, you can set four properties in each button:
android:nextFocusUp-Defines which control gets focus when the up key is clicked
android:nextFocusDown-Defines which control gets focus when the down key is pressed
android:nextFocusLeft-Defines which control gets focus when the left key is clicked
android:nextFocusRight--Defines which control gets focus when the right key is clicked
Here is the code:
Here is the focus switching sequence assuming that key 12 starts pressing down:
Step 4 Set the initial control focus of the interface
When loading each page, you can set the initial control focus in the interface to facilitate the user's positioning operation. You only need to add it to the control. For example:
As a developer, it is important to remember that due to the diversity of Android devices, it is very important for users to easily enter or switch between different controls on the interface. This article briefly introduces how users can customize the focus switching order of controls, which is very beneficial for the user interface experience.
About Android interface design foundation control focus steps are what to share here, hope the above content can have some help to everyone, can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.