Android screen adaptation (using ConstraintLayout), kotlin array sorting

The tutorial is as follows:

1. Pull two horizontal reference lines and set them at 20% and 65% respectively (calculated by the blogger)

insert image description here

2. Then pull an imageView into the layout and choose the picture you want to display

insert image description here

3. Set the upper and lower reference objects of this imageView as two reference lines, and set the left and right reference objects as the parent container. Set its width to wrap_content and its height to mach_constraint (ie 0dp).insert image description here

This picture fits the position well.

Same reason: adapt to the second picture

  1. Create two new lines and set the positions of the two lines at %89 and %93.5 respectively.

  2. Pull an imageView into the layout and choose the picture you want to display

  3. Set the upper and lower reference objects of this imageView as two reference lines, and set the left and right reference objects as the parent container. Set its width to wrap_content and its height to mach_constraint (that is, 0dp).

Finally: Set a background for the ConstraintLayout layout

insert image description here

Two mobile phones and tablet running effect diagrams are as follows

insert image description here

The xml code is as follows

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:app=“http://schemas.android.com/apk/res-auto”

xmlns:tools=“http://schemas.android.com/tools”

android:layout_width=“wrap_content”

android:layout_height=“match_parent”

android:background="@drawable/splash_bg"

tools:context=".MainActivity">

<androidx.constraintlayout.widget.Guideline

android:id="@+id/guideline1"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

app:layout_constraintGuide_percent=“0.65” />

<androidx.constraintlayout.widget.Guideline

android:id="@+id/guideline"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

app:layout_constraintGuide_percent=“0.2” />

<androidx.constraintlayout.widget.Guideline

android:id="@+id/guideline2"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

app:layout_constraintGuide_percent=“0.89” />

<androidx.constraintlayout.widget.Guideline

android:id="@+id/guideline3"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

app:layout_constraintGuide_percent=“0.935” />

<ImageView

android:id="@+id/imageView"

android:layout_width=“wrap_content”

android:layout_height=“0dp”

Summarize

Finally, the editor would like to say: No matter what direction you choose to develop in the future, the most important thing at present is to learn Android technology well. After all, for programmers, there are too many knowledge content and technologies to learn. The only way to eliminate is to constantly improve ourselves. It is always us to adapt to the environment, not the environment to adapt to us!

Attached here are dozens of sets of Android interview questions from Tencent, ByteDance, JD.com, Xiaomi, Toutiao, Ali, Meituan and other companies that I have compiled for 19 years. Organize the technical points into videos and PDFs (in fact, it took a lot more effort than expected), including knowledge context + many details.

Due to limited space, here is a small part of it in the form of pictures.

The detailed arrangement can be seen on GitHub;

Android architecture video + BAT interview topic PDF + study notes

There are a lot of materials for learning Android on the Internet, but if the knowledge you have learned is not systematic, and when you encounter problems, you just taste it and don't study it in depth, then it is difficult to achieve real technical improvement. I hope that this systematic technical system will provide a direction for everyone to refer to.

E8%AF%95%E6%8B%BF%E9%AB%98%E8%96%AA%EF%BC%81.md)**

There are a lot of materials for learning Android on the Internet, but if the knowledge you have learned is not systematic, and when you encounter problems, you just taste it and don't study it in depth, then it is difficult to achieve real technical improvement. I hope that this systematic technical system will provide a direction for everyone to refer to.

The road to technological advancement is very long, let's encourage each other~

Guess you like

Origin blog.csdn.net/m0_66264630/article/details/122945122