At the end of the last post, we had the following picture:
This screen is still a bit shabby as a demo screen, so we’ll embellish it a bit in this article.
Let’s look at the state before the modification:
You put a text message in the outermost layout. Let’s make three changes to this layout.
1. Add an image file.
2. Increase the text size
3. Place the content in the upper center of the screen.
Add image resources
Intercept the DevEco icon and save it as a JPG file, then place it in the Media directory.
Use this file in the ability_main.xml file:
Note the use of oHOs :image_src, which does not require an extension.
Increase text size
Adjust the text size to 100.
Adjust the layout
Add another DirectionalLayout to manage images and text, and add three Components to adjust the spacing between elements.
Execution Result:
For more information about DirectionalLayout, please refer to the official development documentation of Hongmeng:
Developer.harmonyos.com/cn/docs/doc…
Introduce new book
Live Python Design Patterns is the author’s latest book, keep your eyes open!
The book uses Python’s standard GUI toolkit, Tkinter, to illustrate each of the 23 design patterns with executable examples. On the one hand, readers can understand the application scenarios and problems of each design pattern in real software development work. On the other hand, by explaining the process of solving these problems, readers can understand how to judge the advantages and disadvantages of using design patterns when writing code, and make reasonable use of design patterns.
Readers who are interested in design patterns and want to learn and use them can quickly cross the threshold from understanding to using them. Readers wishing to learn Python GUI programming can use the examples in this book as a design and development reference; Readers who use Python for image analysis and data processing can quickly build their own systems based on the examples in this book.
Find this article helpful? Please share it with more people.
Focus on wechat public number [Object-oriented Thinking] Easy learning every day!
Object-oriented development, object-oriented thinking!