<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: wowohaha</title>
    <description>The latest articles on DEV Community by wowohaha (@wowohaha).</description>
    <link>https://dev.to/wowohaha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1246452%2F72e3ea08-3801-43ec-9f5f-68008a80269b.png</url>
      <title>DEV Community: wowohaha</title>
      <link>https://dev.to/wowohaha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wowohaha"/>
    <language>en</language>
    <item>
      <title>Deep Learning: How to Accelerate Application Development</title>
      <dc:creator>wowohaha</dc:creator>
      <pubDate>Tue, 06 Feb 2024 09:10:08 +0000</pubDate>
      <link>https://dev.to/wowohaha/deep-learning-how-to-accelerate-application-development-4dln</link>
      <guid>https://dev.to/wowohaha/deep-learning-how-to-accelerate-application-development-4dln</guid>
      <description>&lt;h1&gt;
  
  
  What is Deep learning?
&lt;/h1&gt;

&lt;p&gt;Deep learning, a subset of machine learning, is inspired by the structure and function of the human brain and is used to create artificial neural networks. These networks are adept at recognizing patterns in data, which has led to innovative applications in various fields, including Computer Vision (CV) and natural language processing (NLP).&lt;/p&gt;

&lt;h1&gt;
  
  
  Applying Deep Learning in Real-World Scenarios
&lt;/h1&gt;

&lt;p&gt;Deep learning has been having a significant impact on countless industries and areas. In the field of Computer Vision, deep learning algorithms can recognize images aiding in tasks like object detection, image segmentation, and even Video Content Analysis. In terms of language models, deep learning has revolutionized how machines understand and generate human languages. Translation services, semantic understanding, and sentiment analysis are areas where deep learning models are widely used.&lt;/p&gt;

&lt;p&gt;Talking in specifics about applications of deep learning in Computer Vision, it has a pivotal role in facial recognition systems, autonomous driving where it aids in detecting objects, and even in healthcare for identifying patterns and anomalies in medical images. Furthermore, in the retail sector, visual search is a function enhanced by deep learning.&lt;/p&gt;

&lt;h1&gt;
  
  
  Accelerating Application Development with Deep Learning
&lt;/h1&gt;

&lt;p&gt;A key area where deep learning in Computer Vision has accelerated application development is in the design-to-code workflow. Traditionally, converting a graphical user interface design into usable code was laborious. However, with deep learning, developers can now automate this process. &lt;/p&gt;

&lt;p&gt;For instance, deep learning models can create code from a design file, improving the productivity and efficiency of developers. Such an application could have deep utility in tools like Figma where a plugin with deep learning capabilities can take a design as input and quickly generate the equivalent frontend code. Additionally, such tools could be used to quickly generate design drafts based on screenshots.&lt;/p&gt;

&lt;p&gt;More interestingly, tools like &lt;a href="https://codia.ai/s/K1F5"&gt;Codia&lt;/a&gt; and Anima are making great strides in this area. &lt;a href="https://codia.ai/s/K1F5"&gt;Codia&lt;/a&gt; leverages artificial intelligence to turn UI designs into code while Anima allows developers to create responsive and interactive web prototypes right from their design tools.&lt;/p&gt;

&lt;h1&gt;
  
  
  conclusion
&lt;/h1&gt;

&lt;p&gt;In conclusion, deep learning is revolutionizing the standard workflows in various areas by introducing faster, efficient methods—application development being one of those areas. With the continual advancements in this field, it can be expected to have an even more significant impact in the future.&lt;/p&gt;

</description>
      <category>androiddev</category>
      <category>deeplearning</category>
      <category>webdev</category>
      <category>cv</category>
    </item>
    <item>
      <title>How to reduce Android Studio's maximum memory footprint</title>
      <dc:creator>wowohaha</dc:creator>
      <pubDate>Sat, 06 Jan 2024 15:03:53 +0000</pubDate>
      <link>https://dev.to/wowohaha/how-to-reduce-android-studios-maximum-memory-footprint-4i50</link>
      <guid>https://dev.to/wowohaha/how-to-reduce-android-studios-maximum-memory-footprint-4i50</guid>
      <description>&lt;p&gt;To reduce Android Studio's maximum memory footprint, you can modify the JVM options in the Android Studio configuration file. By allocating less memory to Android Studio, you can reduce its memory usage. Here are the steps to do this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Android Studio.&lt;/li&gt;
&lt;li&gt;Go to "Help" in the top menu and select "Edit Custom VM Options". This will open the configuration file in the default text editor.&lt;/li&gt;
&lt;li&gt;In the configuration file, you will see the default JVM options for Android Studio.&lt;/li&gt;
&lt;li&gt;Look for the &lt;code&gt;-Xmx&lt;/code&gt; parameter, which specifies the maximum heap size for the JVM.&lt;/li&gt;
&lt;li&gt;Modify the value of &lt;code&gt;-Xmx&lt;/code&gt; to allocate less memory to Android Studio. For example, you can change &lt;code&gt;-Xmx2g&lt;/code&gt; to &lt;code&gt;-Xmx1g&lt;/code&gt; to limit the maximum heap size to 1GB.&lt;/li&gt;
&lt;li&gt;Save the configuration file and restart Android Studio for the changes to take effect.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By reducing the maximum heap size allocated to Android Studio, you can limit its memory usage. However, keep in mind that allocating too little memory may impact the performance of Android Studio, especially when working with large projects. It's recommended to find a balance based on your system resources and the requirements of your projects.&lt;/p&gt;

</description>
      <category>android</category>
      <category>androiddev</category>
      <category>androidstudio</category>
    </item>
    <item>
      <title>Quickly develop your first Android app</title>
      <dc:creator>wowohaha</dc:creator>
      <pubDate>Tue, 02 Jan 2024 09:05:43 +0000</pubDate>
      <link>https://dev.to/wowohaha/quickly-develop-your-first-android-app-26fp</link>
      <guid>https://dev.to/wowohaha/quickly-develop-your-first-android-app-26fp</guid>
      <description>&lt;h2&gt;
  
  
  1. Preface
&lt;/h2&gt;

&lt;p&gt;This article will help you develop your first Android app and learn some basic concepts of Android UI. By the end of this article, you will be able to write simple and some complex Android application UI.&lt;br&gt;&lt;br&gt;
If you don’t understand all the knowledge in this article, don’t worry, this article introduces a &lt;a href="https://codia.ai/s/K1F5"&gt;magic tool&lt;/a&gt; at the end. Using this tool, you can quickly generate code for platforms such as Android and even iOS from the Figma design draft.&lt;/p&gt;

&lt;p&gt;Referring to popular applications and implementing your own version is a good way to learn Android development. This method has a very clear purpose.&lt;br&gt;&lt;br&gt;
Starting today, we start to imitate the twitter application, starting with the &lt;code&gt;Home&lt;/code&gt; page.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_AWhx8Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/156a3ov083wt7715p4ow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_AWhx8Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/156a3ov083wt7715p4ow.png" alt="Twitter Home" width="800" height="1731"&gt;&lt;/a&gt;&lt;br&gt;
You can see that this page is very complex, so we need to learn some basic knowledge of Android UI development first.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Android UI development basics
&lt;/h2&gt;
&lt;h3&gt;
  
  
  2.1. &lt;code&gt;Activity&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;First, let’s introduce &lt;code&gt;Activity&lt;/code&gt;. As one of the four major components of Android, the first program you create when learning Android development will come into contact with &lt;code&gt;Activity&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
&lt;code&gt;Activity&lt;/code&gt; can be understood as a window that draws the user interface. This window can fill the entire screen or float above other windows.  &lt;/p&gt;

&lt;p&gt;Our default &lt;code&gt;Activity&lt;/code&gt; is generally called &lt;code&gt;MainActivity&lt;/code&gt;, and the code is as follows. &lt;code&gt;R.layout.activity_main&lt;/code&gt; is a layout in xml format, which is used to describe what the interface looks like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;MainActivity&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;extends&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;AppCompatActivity&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;  

&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="nd"&gt;@Override&lt;/span&gt;  
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;protected&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Bundle&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;  
&lt;span class="err"&gt;        &lt;/span&gt;&lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;  
        &lt;span class="c1"&gt;//The R file sets a hexadecimal index for each resource file by category,&lt;/span&gt;
&lt;span class="err"&gt;        &lt;/span&gt;&lt;span class="c1"&gt;// It is a final static inner class, which can operate the corresponding resources through R.classname.resourcename.&lt;/span&gt;
&lt;span class="err"&gt;        &lt;/span&gt;&lt;span class="n"&gt;setContentView&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;R&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;activity_main&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;    
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;  
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why &lt;code&gt;MainActivity&lt;/code&gt; can be opened directly when the application is started is because the intent-filter of the corresponding Activity is set in AndroidManifest.xml. After we create the Activity, Android Studio will automatically create the corresponding configuration information in the manifest file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;activity&lt;/span&gt;  
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;".MainActivity"&lt;/span&gt;  
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="na"&gt;android:exported=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;intent-filter&amp;gt;&lt;/span&gt;  
        &lt;span class="c"&gt;&amp;lt;!-- There is only one startup entrance--&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;action&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.intent.action.MAIN"&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;  
        &lt;span class="c"&gt;&amp;lt;!--To set the startup icon in the application list--&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;category&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.intent.category.LAUNCHER"&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;  
    &lt;span class="nt"&gt;&amp;lt;/intent-filter&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/activity&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2. View and ViewGroup
&lt;/h3&gt;

&lt;p&gt;In Android UI development, View and ViewGroup are two very important classes, and the main difference between them lies in their functions and uses.  &lt;/p&gt;

&lt;h4&gt;
  
  
  2.2.1. &lt;a href="https://developer.android.com/reference/android/view/View"&gt;View&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;View is the most basic UI component in Android and it is the base class of all UI components. It provides basic drawing, event handling and other functions. For example, TextView, Button, ImageView, etc. are all subclasses of View. View’s main features include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Drawing: The View class contains the logic for drawing itself. You can customize the drawing logic by inheriting the View class and overriding the onDraw method.&lt;/li&gt;
&lt;li&gt;Event processing: The View class also provides event processing functions, such as click, long press, sliding, etc. You can customize event processing logic by overriding the corresponding event processing methods (such as onClick, onLongClick, onTouchEvent, etc.).
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this article, we mainly focus on the Drawing part of View, which is directly related to how View is displayed.  &lt;/p&gt;

&lt;h5&gt;
  
  
  2.2.1.1. View common properties
&lt;/h5&gt;

&lt;p&gt;First, let's take a look at the common properties of View. These are also the most commonly used properties of each subclass of View, eg. ImageView or TextView.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attributes&lt;/th&gt;
&lt;th&gt;Optional values&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;android:layout_gravity&lt;/td&gt;
&lt;td&gt;center_horizontal, center_vertical, center, left, right, top, buttom&lt;/td&gt;
&lt;td&gt;The gravity bias of the control relative to the parent container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;android:gravity&lt;/td&gt;
&lt;td&gt;center_horizontal, center_vertical, center, left, right, top, buttom&lt;/td&gt;
&lt;td&gt;The gravity bias of the control's own content&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;android:visibility&lt;/td&gt;
&lt;td&gt;visible, invisible, gone&lt;/td&gt;
&lt;td&gt;gone is invisible and does not retain position&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;android:id&lt;/td&gt;
&lt;td&gt;
&lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt;/valName @+id/ValName&lt;/td&gt;
&lt;td&gt;Use existing id by default,+Add new id&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;If you encounter a situation where the background color of Button cannot be changed, the system actually uses the Material theme. We only need to change the Button component to android.widget.Button.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  2.2.2. &lt;a href="https://developer.android.com/reference/android/view/ViewGroup"&gt;ViewGroup&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;ViewGroup is a subclass of View, which is used to accommodate and manage other UI components. The main functions of ViewGroup include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Layout: ViewGroup provides a variety of layout methods, such as LinearLayout, RelativeLayout, etc. These layout methods determine the position and size of its subcomponents.&lt;/li&gt;
&lt;li&gt;Manage subcomponents: ViewGroup provides methods to add, delete, and find subcomponents, allowing you to easily manage UI components.&lt;/li&gt;
&lt;li&gt;Event delivery: ViewGroup is also responsible for event delivery. When an event occurs on a ViewGroup, it passes the event to its child components until it finds the trigger point for the event.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In summary, the main difference between View and ViewGroup is that View is a UI component used for drawing and event handling, while ViewGroup is a container used to accommodate and manage other UI components. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vUjbc0F7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qti042sa264fhsfwt7os.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vUjbc0F7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qti042sa264fhsfwt7os.png" alt="Android View and ViewGroup" width="684" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3. &lt;a href="https://developer.android.com/reference/android/widget/TextView"&gt;TextView&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;TextView is the most commonly used widget, a user interface element that displays text to the user. To provide user-editable text, see &lt;a href="https://developer.android.com/reference/android/widget/EditText"&gt;EditText&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
Below is a demo of TextView. Based on this demo, we will look at the most commonly used properties of TextView.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/txtOne"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"200dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"200dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"TextView_Content"&lt;/span&gt;
        &lt;span class="na"&gt;android:textColor=&lt;/span&gt;&lt;span class="s"&gt;"#EA5246"&lt;/span&gt;
        &lt;span class="na"&gt;android:textStyle=&lt;/span&gt;&lt;span class="s"&gt;"bold|italic"&lt;/span&gt;
        &lt;span class="na"&gt;android:background=&lt;/span&gt;&lt;span class="s"&gt;"#000000"&lt;/span&gt;
        &lt;span class="na"&gt;android:textSize=&lt;/span&gt;&lt;span class="s"&gt;"18sp"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above TextView has the following properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;id: Set a component id for TextView. Based on the id, we can obtain the object through the findViewById() method in the Java/Kotlin code, and then set the relevant properties.&lt;/li&gt;
&lt;li&gt;layout_width: the width of the component, usually written as: &lt;strong&gt;wrap_content&lt;/strong&gt; or &lt;strong&gt;match_parent&lt;/strong&gt;, the former is the size of the control as much as the content displayed by the control, and the latter will fill the parent container where the control is located; of course, it can also be set into a specific size, for example, here I set it to 200dp for display effect.&lt;/li&gt;
&lt;li&gt;layout_height: the height of the component, the content is the same as above.&lt;/li&gt;
&lt;li&gt;gravity: Sets the alignment direction of the content in the control.&lt;/li&gt;
&lt;li&gt;text: Set the displayed text content. Generally, we write the string into the string.xml file, and then obtain the corresponding string content through &lt;a class="mentioned-user" href="https://dev.to/string"&gt;@string&lt;/a&gt;/xxx. For convenience, I will write it directly into "" here. It is not recommended to write like this...&lt;/li&gt;
&lt;li&gt;textColor: Set the font color, the same as above, reference it through the colors.xml resource, don't write it directly.&lt;/li&gt;
&lt;li&gt;textStyle: Set the font style, three optional values: &lt;strong&gt;normal&lt;/strong&gt; (no effect), &lt;strong&gt;bold&lt;/strong&gt; (bold), &lt;strong&gt;italic&lt;/strong&gt; (italic)&lt;/li&gt;
&lt;li&gt;textSize: font size, the unit is usually sp.&lt;/li&gt;
&lt;li&gt;background: The background color of the control, which can be understood as the color that fills the entire control, which can be a picture.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2.4. &lt;a href="https://developer.android.com/reference/android/widget/ImageView"&gt;ImageView&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Displays image resources, for example &lt;a href="https://developer.android.com/reference/android/graphics/Bitmap"&gt;Bitmap&lt;/a&gt; or &lt;a href="https://developer.android.com/reference/android/graphics/drawable/Drawable"&gt;Drawable&lt;/a&gt; resources. ImageView is also commonly used to &lt;a href="https://developer.android.com/reference/android/widget/ImageView#setImageTintMode(android.graphics.PorterDuff.Mode)"&gt;apply tints to an image&lt;/a&gt; and handle &lt;a href="https://developer.android.com/reference/android/widget/ImageView#setScaleType(android.widget.ImageView.ScaleType)"&gt;image scaling&lt;/a&gt;.&lt;br&gt;
The following XML snippet is a common example of using an ImageView to display an image resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt; &lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt;
     &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
     &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
     &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;ImageView&lt;/span&gt;
         &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
         &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
         &lt;span class="na"&gt;android:src=&lt;/span&gt;&lt;span class="s"&gt;"@drawable/my_image"&lt;/span&gt;
         &lt;span class="na"&gt;android:background=&lt;/span&gt;&lt;span class="s"&gt;"@drawable/my_image_background"&lt;/span&gt;
         &lt;span class="na"&gt;android:contentDescription=&lt;/span&gt;&lt;span class="s"&gt;"@string/my_image_description"&lt;/span&gt;
         &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We focus on the following attributes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;layout_width: the width of the component, usually written as: &lt;strong&gt;wrap_content&lt;/strong&gt; or &lt;strong&gt;match_parent&lt;/strong&gt;, the former is how large the content displayed by the control is, and the latter will fill the parent container where the control is located; of course it can also be set into a specific size.&lt;/li&gt;
&lt;li&gt;layout_height: the height of the component, the content is the same as above.&lt;/li&gt;
&lt;li&gt;src: Sets a drawable as the content of this ImageView.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/reference/android/view/View#attr_android:background"&gt;&lt;code&gt;android:background&lt;/code&gt;&lt;/a&gt;: A drawable to use as the background.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2.4.1. The difference between &lt;code&gt;src&lt;/code&gt; attribute and &lt;code&gt;background&lt;/code&gt; attribute:
&lt;/h4&gt;

&lt;p&gt;In the API documentation, we found that ImageView has two attributes that can be used to set images, namely: &lt;code&gt;src&lt;/code&gt; and &lt;code&gt;background&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;background usually refers to &lt;strong&gt;background&lt;/strong&gt;, and src refers to &lt;strong&gt;content&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When using &lt;strong&gt;src&lt;/strong&gt; to fill in a picture, it will be filled directly according to the size of the picture and will not be stretched. When using background to fill in the picture, it will be based on the size given by the ImageView. Width to &lt;strong&gt;stretch&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2.5. &lt;a href="https://developer.android.com/reference/android/widget/FrameLayout"&gt;FrameLayout&lt;/a&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  2.5.1. Why are various Layouts needed?
&lt;/h4&gt;

&lt;p&gt;A rich ui is composed of many controls, so how can we make each control placed on the ui in an orderly manner instead of being messy? This needs to be achieved with the help of layout. Layout is a kind of place that can be used to place a container for many controls, it can adjust the position of the internal controls according to certain rules, thereby writing a beautiful interface. Of course, in addition to placing controls, layouts can also be placed inside the layout. Through the nesting of multi-layer layouts, we can complete some more complex interface implementations, the following figure shows the relationship between them well.&lt;br&gt;&lt;br&gt;
Layout can contain Layout and Widget, and control their layout. Widget only displays content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---Jlkc5Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vdvxf837xzem03w8gc0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---Jlkc5Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vdvxf837xzem03w8gc0.png" alt="Android Layout And Widgets" width="800" height="661"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  2.5.2. Default layout method of FrameLayout
&lt;/h4&gt;

&lt;p&gt;There are six major layouts in Android, namely: LinearLayout, RelativeLayout, FrameLayout, TableLayout, AbsoluteLayout, GridLayout. Among them, FrameLayout can be said to be the simplest layout. This layout directly opens up a blank area on the screen. When we add controls to it, they will be placed in the upper left corner of this area by default, but this layout method does not have any positioning method; the size of the frame layout is determined by the largest sub-control in the control. If the controls are the same size, then only the top component can be seen at the same time! Subsequently added controls will overwrite the previous one! Although the control will be placed in the upper left corner by default, we can also specify other locations through the layout_gravity attribute!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;FrameLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/textView"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"This is Long Long TextView"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/button"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Button"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/FrameLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LfXoYOtd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5f38s8zwmyk1c20o5vi9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LfXoYOtd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5f38s8zwmyk1c20o5vi9.png" alt="Android FrameLayout" width="800" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2.5.3. FrameLayout &lt;code&gt;layout_gravity&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;In addition to this default effect, we can also use the &lt;code&gt;layout_gravity&lt;/code&gt; attribute to specify the alignment of the control in the layout, which is similar to the usage in LinearLayout. Follows is a example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;FrameLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/textView"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_gravity=&lt;/span&gt;&lt;span class="s"&gt;"left"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"This is Long Long TextView"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/button"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_gravity=&lt;/span&gt;&lt;span class="s"&gt;"right"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Button"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/FrameLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4-T5e_UE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hxl1pfoa8j3lm2k9ztt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4-T5e_UE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hxl1pfoa8j3lm2k9ztt.png" alt="Andorid FrameLayout layout_gravity" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  2.5.3.1. The value of &lt;code&gt;layout_gravity&lt;/code&gt;
&lt;/h5&gt;

&lt;p&gt;There are many values for layout_gravity. You can explore more in practice and try different values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;    &lt;span class="c"&gt;&amp;lt;!-- Standard gravity constant that a child supplies to its parent.
         Defines how the child view should be positioned, on both the X and Y axes, within its enclosing layout. --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;attr&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"layout_gravity"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Push object to the top of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"top"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x30"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Push object to the bottom of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"bottom"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x50"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Push object to the left of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"left"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x03"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Push object to the right of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"right"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x05"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Place object in the vertical center of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"center_vertical"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x10"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Grow the vertical size of the object if needed so it completely fills its container. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"fill_vertical"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x70"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Place object in the horizontal center of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"center_horizontal"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x01"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Grow the horizontal size of the object if needed so it completely fills its container. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"fill_horizontal"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x07"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x11"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"fill"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x77"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Additional option that can be set to have the top and/or bottom edges of
             the child clipped to its container's bounds.
             The clip will be based on the vertical gravity: a top gravity will clip the bottom
             edge, a bottom gravity will clip the top edge, and neither will clip both edges. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"clip_vertical"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x80"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Additional option that can be set to have the left and/or right edges of
             the child clipped to its container's bounds.
             The clip will be based on the horizontal gravity: a left gravity will clip the right
             edge, a right gravity will clip the left edge, and neither will clip both edges. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"clip_horizontal"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x08"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Push object to the beginning of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"start"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x00800003"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Push object to the end of its container, not changing its size. --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;flag&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"end"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0x00800005"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/attr&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.6. &lt;a href="https://developer.android.com/reference/android/widget/LinearLayout"&gt;LinearLayout&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A layout that arranges other views either horizontally in a single column or vertically in a single row.&lt;br&gt;
The following snippet shows how to include a linear layout in your layout XML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
   &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
   &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
   &lt;span class="na"&gt;android:paddingLeft=&lt;/span&gt;&lt;span class="s"&gt;"16dp"&lt;/span&gt;
   &lt;span class="na"&gt;android:paddingRight=&lt;/span&gt;&lt;span class="s"&gt;"16dp"&lt;/span&gt;
   &lt;span class="na"&gt;android:orientation=&lt;/span&gt;&lt;span class="s"&gt;"horizontal"&lt;/span&gt;
   &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

   &lt;span class="c"&gt;&amp;lt;!-- Include other widget or layout tags here. These are considered
           "child views" or "children" of the linear layout --&amp;gt;&lt;/span&gt;

 &lt;span class="nt"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this section, we will analyze each important attribute of LinearLayout in detail.  &lt;/p&gt;

&lt;h4&gt;
  
  
  2.6.1. Important attributes of LinearLayout
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Common properties

&lt;ul&gt;
&lt;li&gt;orientation: The arrangement of components in the layout, horizontal/vertical.&lt;/li&gt;
&lt;li&gt;gravity: controls the alignment of child elements contained in the component, and can be combined in multiple values, such as &lt;code&gt;left|buttom&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;layout_gravity: controls the alignment of the component in the parent container&lt;/li&gt;
&lt;li&gt;layout_width: the width of the layout, usually do not write the number directly, use wrap_content (actual size of the component)/match_parent (fill the parent container)&lt;/li&gt;
&lt;li&gt;layout_height: the height of the layout, the parameters are as above&lt;/li&gt;
&lt;li&gt;id: Set a resource id for the component. The component can be found through findViewById(id) in the java/kotlin file.&lt;/li&gt;
&lt;li&gt;background: Set a background image for this component, or directly cover it with color&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;weight: This attribute is used to divide areas equally proportionally&lt;/li&gt;
&lt;li&gt;divider line: used to set dividing line pictures for LinearLayout, through showDividers

&lt;ul&gt;
&lt;li&gt;divider: Set the dividing line image&lt;/li&gt;
&lt;li&gt;showDividers: Set the position of the dividing line, there are four optional values: none/middle/begining/end&lt;/li&gt;
&lt;li&gt;dividerPadding: Set the padding of the dividing line&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The layout_gravity of LinearLayout is the same as that of FrameLayout, so I won’t explain it in detail here. We mainly talk about its unique attr: &lt;code&gt;weight&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.6.2. &lt;code&gt;weight&lt;/code&gt; attribute usage
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt;
    &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/LinearLayout1"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:orientation=&lt;/span&gt;&lt;span class="s"&gt;"horizontal"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"0dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_weight=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt;
        &lt;span class="na"&gt;android:background=&lt;/span&gt;&lt;span class="s"&gt;"#ADFF2F"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"0dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_weight=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt;
        &lt;span class="na"&gt;android:background=&lt;/span&gt;&lt;span class="s"&gt;"#DA70D6"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cbTbh1u---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w64ci9b15ziv1vui2r5x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cbTbh1u---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w64ci9b15ziv1vui2r5x.png" alt="Android LinearLayout Weight" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To achieve the effect of 1:2, you only need to set the &lt;code&gt;android:width&lt;/code&gt; attribute of the two LinearLayouts to 0dp and change &lt;code&gt;layout_weight&lt;/code&gt; to 1 and 2 respectively.  &lt;/p&gt;

&lt;h4&gt;
  
  
  2.6.3. Simple example of LinearLayout
&lt;/h4&gt;

&lt;p&gt;Here is a simple LinearLayout example, you can refer to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt;
    &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/LinearLayout1"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:orientation=&lt;/span&gt;&lt;span class="s"&gt;"vertical"&lt;/span&gt;
    &lt;span class="na"&gt;tools:context=&lt;/span&gt;&lt;span class="s"&gt;".MainActivity"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Please enter the phone number:"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;EditText&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;LinearLayout&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"right"&lt;/span&gt;
        &lt;span class="na"&gt;android:orientation=&lt;/span&gt;&lt;span class="s"&gt;"horizontal"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
            &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"save"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

        &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
            &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
            &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"clear"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j7xw6K18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtu00ds8y4qdhedq4vmw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j7xw6K18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtu00ds8y4qdhedq4vmw.png" alt="Android LinearLayout Example" width="800" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also refer to the examples on the Android official website: &lt;a href="https://developer.android.com/develop/ui/views/layout/linear"&gt;Create a linear layout&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.7. &lt;a href="https://developer.android.com/reference/android/widget/RelativeLayout"&gt;RelativeLayout&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A Layout where the positions of the children can be described in relation to each other or to the parent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.android.com/reference/android/widget/RelativeLayout"&gt;RelativeLayout&lt;/a&gt; is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent &lt;a href="https://developer.android.com/reference/android/widget/RelativeLayout"&gt;RelativeLayout&lt;/a&gt; area (such as aligned to the bottom, left or center).&lt;/p&gt;

&lt;p&gt;Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. For example, you cannot have a RelativeLayout whose height is set to &lt;a href="https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#WRAP_CONTENT"&gt;WRAP_CONTENT&lt;/a&gt; and a child set to &lt;a href="https://developer.android.com/reference/android/widget/RelativeLayout#ALIGN_PARENT_BOTTOM"&gt;ALIGN_PARENT_BOTTOM&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;In this section, we will analyze each important attribute of RelativeLayout in detail.  &lt;/p&gt;

&lt;h4&gt;
  
  
  2.7.1. Important properties of RelativeLayout
&lt;/h4&gt;

&lt;p&gt;We divide them according to 'Basic properties'/'Position based on parent container'/'Position based on sibling components'/'margin'/'padding'. This will make it easier for everyone to understand and remember.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic properties

&lt;ul&gt;
&lt;li&gt;gravity: Set the alignment of components within the container&lt;/li&gt;
&lt;li&gt;ignoreGravity: Components that set this attribute to true will not be affected by the gravity attribute.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Position based on parent container

&lt;ul&gt;
&lt;li&gt;layout_alignParentLeft: left aligned&lt;/li&gt;
&lt;li&gt;layout_alignParentRight: align right&lt;/li&gt;
&lt;li&gt;layout_alignParentTop: top alignment&lt;/li&gt;
&lt;li&gt;layout_alignParentBottom: bottom alignment&lt;/li&gt;
&lt;li&gt;android:layout_centerHorizontal: horizontally centered&lt;/li&gt;
&lt;li&gt;android:layout_centerVertical: vertical centering&lt;/li&gt;
&lt;li&gt;android:layout_centerInParent: middle position&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Position based on sibling components:

&lt;ul&gt;
&lt;li&gt;layout_toLeftOf: refers to the left side of the component&lt;/li&gt;
&lt;li&gt;layout_toRightOf: refers to the right side of the component&lt;/li&gt;
&lt;li&gt;layout_above: reference component above&lt;/li&gt;
&lt;li&gt;layout_below: refers to below the component&lt;/li&gt;
&lt;li&gt;layout_alignTop: aligns the top border of the reference component&lt;/li&gt;
&lt;li&gt;layout_alignBottom: aligns the lower border of the reference component&lt;/li&gt;
&lt;li&gt;layout_alignLeft: aligns the left edge of the reference component&lt;/li&gt;
&lt;li&gt;layout_alignRight: aligns the bounded reference component&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;margin: Set the offset between the component and the parent container

&lt;ul&gt;
&lt;li&gt;layout_margin: Set the offset value of the component's top, bottom, left and right&lt;/li&gt;
&lt;li&gt;layout_marginLeft: Set the offset value of the component from the left&lt;/li&gt;
&lt;li&gt;layout_marginRight: Set the offset value of the component from the right&lt;/li&gt;
&lt;li&gt;layout_marginTop: Set the offset value of the component from the top&lt;/li&gt;
&lt;li&gt;layout_marginBottom: Set the offset value of the component from the bottom&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;padding: Set the margin between elements inside the component

&lt;ul&gt;
&lt;li&gt;android:padding: Padding a certain margin to the top, bottom, left and right of internal elements&lt;/li&gt;
&lt;li&gt;android:paddingLeft: pad a certain margin to the left of the internal element&lt;/li&gt;
&lt;li&gt;android:paddingRight: pad a certain margin to the right of the internal element&lt;/li&gt;
&lt;li&gt;android:paddingTop: Padding a certain margin above the internal elements&lt;/li&gt;
&lt;li&gt;android:paddingBottom: pad a certain margin below the internal element&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2.7.2. Position based on parent container
&lt;/h4&gt;

&lt;p&gt;When an element is positioned according to its parent container, the following diagram can be used to describe the meaning of each attribute.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g4eXADY1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hg6i55azmxf5iypa9nn2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g4eXADY1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hg6i55azmxf5iypa9nn2.png" alt="Android RelativeLayout parent container position" width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2.7.3. Position based on sibling components
&lt;/h4&gt;

&lt;p&gt;Well, let’s first talk about what sibling components are. The so-called sibling components are components in the same level container, as shown in the figure:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cR8k4SIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mro18nrfl5a367tom9ls.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cR8k4SIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mro18nrfl5a367tom9ls.png" alt="Android Relativelayout Sibling Position" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Widget 1 and 2 in the picture are sibling components, and widget 3 is not a sibling component to widget 1 or widget 2, so widget 3 cannot be positioned through widget 1 or 2. For example, layout_toleftof = "widget 1" will report an error. . Remember. The most classic example of the positioning of this sibling component is the "+ layout". The following code implements it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;RelativeLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt;
    &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/RelativeLayout1"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- container center --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/center"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_centerInParent=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Home"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- left of center --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/left"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_centerVertical=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_toLeftOf=&lt;/span&gt;&lt;span class="s"&gt;"@id/center"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Github"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- right of center --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/right"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_centerVertical=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_toRightOf=&lt;/span&gt;&lt;span class="s"&gt;"@id/center"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"OneDrive"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- top of center--&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/top"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_above=&lt;/span&gt;&lt;span class="s"&gt;"@id/center"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_centerHorizontal=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Android"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- bottom of center --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/bottom"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"80dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_below=&lt;/span&gt;&lt;span class="s"&gt;"@id/center"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_centerHorizontal=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:gravity=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Apple"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bYxgFhCf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hu6rsyh8lw9zn8bzpym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bYxgFhCf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hu6rsyh8lw9zn8bzpym.png" alt="Android RelativeLayout Example" width="800" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2.7.4. The difference between margin and padding
&lt;/h4&gt;

&lt;p&gt;Beginners may be a little confused about these two properties, let’s distinguish them here: First, margin represents offset, for example, marginleft = "5dp" means that the component is offset by 5dp from the left edge of the container; while padding represents padding, and the padding object is for the elements in the component. For example, if the text in TextView is set to paddingleft = "5dp" for TextView, 5dp space will be filled to the left of the element in the component. The margin is for the component in the container, and Padding refers to the elements in the component and needs to be distinguished. &lt;/p&gt;

&lt;p&gt;The following is a simple code to demonstrate the difference between the two:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;RelativeLayout&lt;/span&gt; &lt;span class="na"&gt;xmlns:android=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;
    &lt;span class="na"&gt;xmlns:tools=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.android.com/tools"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"match_parent"&lt;/span&gt;
    &lt;span class="na"&gt;android:paddingLeft=&lt;/span&gt;&lt;span class="s"&gt;"10dp"&lt;/span&gt;
    &lt;span class="na"&gt;android:paddingTop=&lt;/span&gt;&lt;span class="s"&gt;"30dp"&lt;/span&gt;
    &lt;span class="na"&gt;android:paddingRight=&lt;/span&gt;&lt;span class="s"&gt;"50dp"&lt;/span&gt;
    &lt;span class="na"&gt;android:paddingBottom=&lt;/span&gt;&lt;span class="s"&gt;"320dp"&lt;/span&gt;
    &lt;span class="na"&gt;tools:context=&lt;/span&gt;&lt;span class="s"&gt;".MainActivity"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/btn1"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Button 1"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_toRightOf=&lt;/span&gt;&lt;span class="s"&gt;"@id/btn1"&lt;/span&gt;
        &lt;span class="na"&gt;android:paddingLeft=&lt;/span&gt;&lt;span class="s"&gt;"100dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Button 2"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:id=&lt;/span&gt;&lt;span class="s"&gt;"@+id/btn3"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_alignParentBottom=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Button 3"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_width=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_height=&lt;/span&gt;&lt;span class="s"&gt;"wrap_content"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_alignParentBottom=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_marginLeft=&lt;/span&gt;&lt;span class="s"&gt;"100dp"&lt;/span&gt;
        &lt;span class="na"&gt;android:layout_toRightOf=&lt;/span&gt;&lt;span class="s"&gt;"@id/btn3"&lt;/span&gt;
        &lt;span class="na"&gt;android:text=&lt;/span&gt;&lt;span class="s"&gt;"Button 4"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DWuEBCpe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ddqt1i8z14vcoj5s8z9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DWuEBCpe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ddqt1i8z14vcoj5s8z9.png" alt="Android Margin vs Padding" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2.7.5. A very common point: margin can be set to a negative number
&lt;/h4&gt;

&lt;p&gt;I believe many friends don’t know this. We are usually used to using positive numbers when setting margins. In fact, we can use negative numbers, which can be very useful in some scenarios.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.8. &lt;a href="https://m3.material.io/"&gt;Material Design&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In fact, for a long time, most people may think that the UI of the Android system is not beautiful, at least not as beautiful as the iOS system. Therefore, the standard Android interface design style is not particularly accepted by the public. Many companies feel that they can design something more beautiful. The interface style of the Android platform has been difficult to unify for a long time. In order to solve this problem, Google also used its trump card and launched a new interface design language - Design Material at the 2014 Google I/O conference.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.8.1. What is Material Design
&lt;/h4&gt;

&lt;p&gt;Material Design is a new interface design language developed by Google's design engineers based on traditional excellent design principles, combined with rich creativity and science and technology. It includes visual, motion, interactive effects and other features. So why does Google think that Can Material Design solve the problem of inconsistent interface styles on the Android platform? In a word, it looks good.  &lt;/p&gt;

&lt;p&gt;In order to set an example, Google has designed all built-in applications using the Material Design style starting from the Android 5.0 system.&lt;/p&gt;

&lt;p&gt;However, after its heavy launch, the popularity of Material Design is not particularly ideal. Because this is only a recommended design specification, mainly for UI designers, not developers. Many developers may not be able to do it at all. It is clear what kind of interface and effects are called Material Design. Even if you understand it, it will be very difficult to implement, because many Material Design effects are difficult to achieve, and Android almost does not provide corresponding API support. It is basically necessary to It's up to the developers themselves to write it from scratch.  &lt;/p&gt;

&lt;p&gt;Google is certainly aware of this problem, so it launched a Design Support library at the 2015 Google I/O conference. This library encapsulates some of the most representative controls and effects in Material Design, allowing developers to Once you understand Material Design, you can easily make your own applications Material. Later, the Design Support library was renamed the Material library, which is used to provide Material Design support for Google's full platform products.&lt;/p&gt;

&lt;p&gt;Taken together, Material Design is an adaptable system of guidelines, components, and tools that supports best practices in user interface design. Powered by open source code, Material Design simplifies collaboration between designers and developers, and help teams build beautiful products quickly. Material Design gives us a guide to deal with UI/UX for Android, Flutter, and the Web.&lt;/p&gt;

&lt;p&gt;Currently, the latest version of Material Design is 3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://m3.material.io/"&gt;Material Design official website&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Material abstracts various commonly used components and provides documentation &lt;a href="https://m3.material.io/components"&gt;material components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For example, we will use &lt;a href="https://github.com/material-components/material-components-android/blob/master/docs/components/BottomNavigation.md"&gt;Material Design Android BottomNagigation&lt;/a&gt; below.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Start implementing &lt;code&gt;Home&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;We use Android Studio to create an &lt;code&gt;Empty Views Activity&lt;/code&gt; to get started.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nFN5W-iQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj4feoh1gv65klubo4b1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nFN5W-iQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj4feoh1gv65klubo4b1.png" alt="Android Twitter New Project" width="800" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project configuration is here, you can do whatever you want. The following is the configuration I use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PdyN8Uxj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfr19pl2xloh498rorm8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PdyN8Uxj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfr19pl2xloh498rorm8.png" alt="Android Twitter New Project Config" width="800" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1. How to implement 'top bar'
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TtC8tsZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9vx2llceb1fj6kyvheo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TtC8tsZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9vx2llceb1fj6kyvheo.png" alt="Twitter Top Bar" width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We use FrameLayout to restore the top bar. This may not be the most suitable for actual production use, but it is the simplest and makes it easier for us to understand how to write Android XML to restore the layout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6ZXek0xF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wq636z3bwmc93fx1e6b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6ZXek0xF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wq636z3bwmc93fx1e6b.png" alt="Android Twitter Layout Top Bar" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three icons are arranged in a row. The account on the left &lt;code&gt;android:layout_gravity="start"&lt;/code&gt; means arranged on the left, &lt;code&gt;android:layout_marginStart="20dp"&lt;/code&gt; from the left boundary constraint, which is a common writing method.&lt;br&gt;&lt;br&gt;
The middle logo, &lt;code&gt;android:layout_gravity="center_horizontal"&lt;/code&gt;, is centered horizontally.&lt;br&gt;&lt;br&gt;
The feature icon on the right &lt;code&gt;android:layout_gravity="end"&lt;/code&gt; means arranging to the right, plus &lt;code&gt;android:layout_marginEnd="20dp"&lt;/code&gt; constrains the distance to the right.&lt;br&gt;&lt;br&gt;
&lt;code&gt;start&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; here are abstract generalizations of &lt;code&gt;left&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt;, because text not only exists left to right, but also exists right to left.&lt;/p&gt;

&lt;p&gt;The left side of the picture below is our code, and the right side is the running effect. Android Studio has a Design view, which can easily see the actual running effect of xml.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NwljNXuW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zapbpswimvhgbzbo2ug3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NwljNXuW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zapbpswimvhgbzbo2ug3.png" alt="Android Twitter Layout Top Bar Result" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because the top bar is a relatively independent interface, we put it in &lt;code&gt;layout_top_bar.xml&lt;/code&gt; and reference this layout through include in &lt;code&gt;activity_main.xml&lt;/code&gt;, adding &lt;code&gt;android:layout_marginTop="20dp"&lt;/code&gt; &lt;code&gt;android: layout_alignParentTop="true"&lt;/code&gt; means aligned with the top of the parent layout, 20dp from the top.&lt;br&gt;&lt;br&gt;
Run the app at this time and you will see the effect on the right side of the picture above.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2. How to implement the 'bottom Navigation Bar'
&lt;/h3&gt;

&lt;p&gt;Next, let’s implement the bottom navigation bar.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vpg99TUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tkw447m5ldomn1d4psf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vpg99TUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tkw447m5ldomn1d4psf.png" alt="Twitter Navigation Bar" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the bottom navigation bar, in the material design specification, a high-order component &lt;code&gt;BottomNavigationView&lt;/code&gt; is specially extracted, so we use this component directly here.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CKKy1xRw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocb6k7kwy44ql3w8f5il.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CKKy1xRw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocb6k7kwy44ql3w8f5il.png" alt="Android Twitter Navigation Bar" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By introducing &lt;code&gt;BottomNavigationView&lt;/code&gt; and simply configuring the menu, we can display the Navigation Bar above.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fs5hfgRG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hlbuapf15jkrl4c5rrl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fs5hfgRG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hlbuapf15jkrl4c5rrl.png" alt="BottomNavigationView" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;BottomNavigationView&lt;/code&gt; supports rich configurations, as shown above, and its supported configurations are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(1) Container&lt;/li&gt;
&lt;li&gt;(2) Icon&lt;/li&gt;
&lt;li&gt;(3) Label text&lt;/li&gt;
&lt;li&gt;(4) Active indicator&lt;/li&gt;
&lt;li&gt;(5) Small badge (optional)&lt;/li&gt;
&lt;li&gt;(6) Large badge (optional)&lt;/li&gt;
&lt;li&gt;(7) Large badge number
For details, please refer to &lt;a href="https://github.com/material-components/material-components-android/blob/master/docs/components/BottomNavigation.md"&gt;BottomNavigationView&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.3. How to implement 'Tweet Item'
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GGJq8VNN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7lpjmrq16a9p7ldxdg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GGJq8VNN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7lpjmrq16a9p7ldxdg7.png" alt="Tweet Item" width="800" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the most complex page we have encountered so far. Let’s first try to split this into familiar components.    &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--03s_QXFD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cagajhf781ypaf2kuyx5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--03s_QXFD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cagajhf781ypaf2kuyx5.png" alt="Tweet Item Split" width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this way, we divide the complex interface into modules that we are familiar with.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vBnDxjhA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bpbxb7s58wzu6460whr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vBnDxjhA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bpbxb7s58wzu6460whr.png" alt="Android Twitter Tweet Item Result" width="800" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We implement this interface according to the idea of splitting. We can see that it takes 135 lines to implement this uncomplicated interface. Moreover, our xml only considers interface restoration, and there are many details that have not been implemented. It can be seen that writing UI is a a complex and time-consuming work.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.4. Multiple Tweet Item + Top + Navigation are spliced together to form a complete page
&lt;/h3&gt;

&lt;p&gt;At this point, we try to integrate our previous work into an complete interface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CHacl0Kv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmjls8a07hnj57k7vjly.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CHacl0Kv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmjls8a07hnj57k7vjly.png" alt="Android Twiter Result" width="800" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown in the picture above, we use LinearLayout to display multiple tweet items. In the actual project, RecyclerView should be used here, but expanding too much will be too complicated and dampen everyone's enthusiasm, so here we first use LinearLayout to indicate multiple tweets.&lt;/p&gt;

&lt;p&gt;Run the App, the effect is as follows:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qBg97-P6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cg338guagr9i4vug451.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qBg97-P6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cg338guagr9i4vug451.png" alt="Twitter Simulator Screenshot" width="800" height="1778"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, at this point, we have restored a part of the design draft, about 5% (╥╯^╰╥)&lt;br&gt;&lt;br&gt;
There is still 95% of the work that needs to be done. We also need to implement different Tweet styles, ScrollView scrolling, RecyclerView lists, etc. Have you ever found that restoring a page is so complicated and workload-intensive?&lt;br&gt;&lt;br&gt;
I am not going to continue with the remaining content in this article, otherwise putting too much content into one article will greatly dampen everyone’s interest in reading and learning.&lt;br&gt;&lt;br&gt;
Next, I will introduce a magic tool that can quickly restore the UI interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Magic tool - Codia quickly generates code
&lt;/h2&gt;

&lt;p&gt;I won’t go into details here, you can go to their official website to learn more.&lt;br&gt;&lt;br&gt;
&lt;a href="https://codia.ai/docs/getting-started/figma-to-android.html"&gt;figma to android&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Their plugins support code generation for multiple platforms including Web/Android/iOS.&lt;br&gt;&lt;br&gt;
&lt;a href="https://codia.ai/s/K1F5"&gt;figma codia plugin&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C_3HKAWy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://codia.ai/images/docs/plugin-cover.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C_3HKAWy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://codia.ai/images/docs/plugin-cover.png" alt="codia plugin" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the Figma design draft, simply click to generate the code, and run it locally to see the generated effect.&lt;br&gt;&lt;br&gt;
You can see that the restoration is very good. It can save everyone a lot of restoration time.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EoIqAE80--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://codia.ai/images/docs/getting-started/run_on_android_simulator.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EoIqAE80--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://codia.ai/images/docs/getting-started/run_on_android_simulator.png" alt="run on Android simulator" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Android Development Study Guide
&lt;/h2&gt;

&lt;p&gt;That ends the content about Twitter page restoration. Finally, we provide an Android development learning route guide to facilitate everyone from getting started to becoming proficient.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.1. &lt;strong&gt;Phase 1: Java Basics&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Basic computer knowledge, computer basics, JDK environment installation and configuration, environment variable configuration, etc.&lt;/li&gt;
&lt;li&gt;Object-oriented abstraction, encapsulation, inheritance, polymorphism, classes and objects, object initialization and recycling; constructor, this keyword, method and method parameter passing process, static keyword, inner class, Java garbage collection mechanism.&lt;/li&gt;
&lt;li&gt;Introduction to common classes and regular expressions.&lt;/li&gt;
&lt;li&gt;Introduction to Java collections: Collection, Set, List, ArrayList, Vector, LinkedList, Hashset, TreeSet, Map, HashMap, TreeMap, Iterator, Enumeration and other common collection APIs.&lt;/li&gt;
&lt;li&gt;Android exception handling, capture of various exceptions, principles of exception mechanism and custom exceptions.&lt;/li&gt;
&lt;li&gt;Java I/O input and output streams: File and FileRandomAccess classes, byte streams InputStream and OutputStream, character streams Reader and Writer, and corresponding implementation classes, IO performance analysis, byte and character conversion streams, and the concept of packaging streams, As well as commonly used packaging categories, computer coding.&lt;/li&gt;
&lt;li&gt;Multi-threading principle: how to create multi-threads (Thread, Runnable) in the program, thread safety issues, thread synchronization, communication between threads, and deadlock.&lt;/li&gt;
&lt;li&gt;Socket network programming.&lt;/li&gt;
&lt;li&gt;Reflection&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5.2. &lt;strong&gt;Phase 2: Android core foundation&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Basic concepts and key points of Android programming, Android project structure analysis, file system, data storage and access, Intent and IntentFilter
&lt;/li&gt;
&lt;li&gt;Android's four core components include monitoring ContentProvider data, Sqlite database addition, deletion, modification and transaction management, and ListView to implement data list display.
&lt;/li&gt;
&lt;li&gt;Android network programming, Apache Commons toolkit introduces the method of using the Get method to submit data to the server, the method of parsing the server response data, the method of using the POST method to submit data to the server, the method of submitting non-text data to the server, and the use The Http protocol implements multi-thread downloading and uses the Http protocol to implement breakpoint resume downloading.
&lt;/li&gt;
&lt;li&gt;Multimedia programming, playing music and videos, introduction to audio and video coding, operating cameras, photo albums, etc.
&lt;/li&gt;
&lt;li&gt;New features, attribute animation, ViewPager, ActonBar, theme style internationalization, etc.
&lt;/li&gt;
&lt;li&gt;Code version management, Git.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5.3. &lt;strong&gt;The third stage: android UI programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Android development environment setup:
Android introduction
Android development environment setup
first Android application
Android application directory structure
&lt;/li&gt;
&lt;li&gt;Usage of Android primary controls:
Use of TextView control
How to use Button control
How to use the EditText control
How to use ImageView
How to use RadioButton
How to use Checkbox
How to use Menu
&lt;/li&gt;
&lt;li&gt;Usage of Android advanced controls:
How to use Autocompletion
How to use ListView
How to use GridView
How to use Adapter
How to use Spinner
How to use Gallery
How to use ScrollView
&lt;/li&gt;
&lt;li&gt;Use of dialog boxes and menus:
Basic concepts of Dialog
How to use AlertDialog
How to use DatePickerDialog
How to use Menu
How to implement custom Menu
&lt;/li&gt;
&lt;li&gt;Layout method of controls:
How to use linear layout
How to use relative layout
How to use table layout
&lt;/li&gt;
&lt;li&gt;Multiple Activity Management:
The role of AndroidManifest.xml file
How to use Intent
How to pass data using Intent
How to start Activity
How to use IntentFilter
How to use Activity Group
&lt;/li&gt;
&lt;li&gt;Custom control implementation method:
Implementation method of custom ListView
How to use collapsible ListView
Implementation method of custom Adapter
Implementation method of custom View
How to implement dynamic control layout
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5.4. &lt;strong&gt;Phase 4: Android Project Advanced&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Internet client projects, push, data refresh, dynamic interaction of html and javascript, demand analysis, etc.
&lt;/li&gt;
&lt;li&gt;Electronic application market project, overall project framework design, observer mode, factory mode, version mode, third-level image cache, memory optimization, attribute animation, compatibility processing of various packages, View principles and measurement of touch events, Distribution of View events, etc.
&lt;/li&gt;
&lt;li&gt;Advanced use of development tools and use of features and permissions of various versions of Android, etc.
&lt;/li&gt;
&lt;li&gt;Open source framework collection, understanding and using various latest open source frameworks can maximize development efficiency.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5.5. &lt;strong&gt;Phase 5: android mobile phone hardware management&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Map and positioning technology: Introduction to GPS; how to use LocationManager; how to add markers on Google Map; how to query buildings near a place; use Google Map to achieve point-to-point navigation.
&lt;/li&gt;
&lt;li&gt;How to use sensors: Use of sensors such as direction, acceleration (gravity), light, magnetic field, distance, temperature, etc.
&lt;/li&gt;
&lt;li&gt;Near field communication technology: Introduction to NFC technology; NFC technology is introduced using scenarios; NFC technology implementation methods.
&lt;/li&gt;
&lt;li&gt;Media management technology: How to use MediaPlayer.
&lt;/li&gt;
&lt;li&gt;Touch screen technology: gesture recognition; multi-touch technology.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5.6. &lt;strong&gt;Phase 6: Android Graphics Programming Technology&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Graphics processing basics: 2D graphics programming basics;
&lt;/li&gt;
&lt;li&gt;Drawing methods of basic graphic elements such as points, lines, and surfaces;
&lt;/li&gt;
&lt;li&gt;Introduction to Android animation framework;
&lt;/li&gt;
&lt;li&gt;Implementation method of displacement animation;
&lt;/li&gt;
&lt;li&gt;How to implement fade-in and fade-out animation;
&lt;/li&gt;
&lt;li&gt;How to implement rotation animation;
&lt;/li&gt;
&lt;li&gt;How to use the Matrix.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  5.7. &lt;strong&gt;Phase 7: Android Game Development&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Android game development: Overview of Android game development;
&lt;/li&gt;
&lt;li&gt;How to use SurfaceView;
&lt;/li&gt;
&lt;li&gt;Physical ball technology;
&lt;/li&gt;
&lt;li&gt;Collision detection technology;
&lt;/li&gt;
&lt;li&gt;How to use resources such as pictures, text, and background music;
&lt;/li&gt;
&lt;li&gt;Basic concepts of game engines;
&lt;/li&gt;
&lt;li&gt;How to use OpenGL ES;
&lt;/li&gt;
&lt;li&gt;How to use Unity engine.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At the same time, you can learn to use various plugins and tools such as Codia to quickly improve your development efficiency.&lt;/p&gt;

&lt;p&gt;This article ends here. In the new year, I hope everyone will gain more knowledge and advance in their career.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Links
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/working-with-the-textview-in-android/"&gt;working with the textview in android&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://developer.android.com/develop/ui/views/layout/declaring-layout"&gt;Develop your app's layout&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>twitter</category>
      <category>java</category>
      <category>kotlin</category>
    </item>
  </channel>
</rss>
