In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to introduce custom layout in Android, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Mode of realization
There are two main processes to make a custom layout interface.
Construct the layout of a graphical interface
Reference to the implementation of graphical interface writing
Construct a graphical interface
We create a layout source file under the layout folder named title
We set a title, with the function name on the left, the user and the current organization on the right, as shown in the following figure
The code in xml is as follows:
Reference to the implementation of graphical interface writing
Create a class that inherits the RelativeLayout layout we just did, dynamically load the layout we just set, and then write specific functions to complete the setting of a custom control.
We can see that we can load the layout file through Layoutinflater.from in the layout above, load three TextView controls in the constructor, and then write two implementation methods to assign values to the text box.
At this point, even if the implementation of the custom layout file is complete, let's take a look at how to load the layout.
Implement loading custom layout
Let's build a new TestActivity.
To convert to the layout file, we refer to the layout we have just defined, named titlelayout
Then return to the code file we wrote the corresponding way, loaded the TitleLayout, and then write the implementation method.
Next, let's take a look at the effect of the implementation.
On how to introduce custom layout in Android to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.