Android Support Library custom viewing guidelines in Java

The Android support library is a group of compatibility libraries and tools on the Android devices provided by different versions.One of the important components is Android Support Library. Android Support Library provides a large number of customized views that enable developers to create a unique user interface according to their needs.This article will introduce how to use SUPPORT LIBRARY in Android applications to define viewing and provide some Java code examples. The first step of using the SUPPORT LIBRARY to customize the view is to ensure that your project already contains the required SUPPORT LIBRARY.It can be achieved by adding dependencies in the project's Build.gradle file.As follows: gradle implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:design:28.0.0' Once I introduced the support library, you can start custom view.The following is an example that shows how to create a button with a custom background color and text: import android.content.Context; import android.support.v7.widget.AppCompatButton; import android.util.AttributeSet; public class CustomButton extends AppCompatButton { public CustomButton(Context context) { super(context); init(); } public CustomButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CustomButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init() { setBackgroundColor(getResources().getColor(R.color.custom_button_background)); setText("Click me"); } } In the above example, we created a custom button class called CustomButton, which inherited from the AppCompatButton class.We have rewritten three constructors and call an init () method in each constructor.In the init () method, we set the custom background color and text for the button. To use the custom button in the layout file, just declare it like using a normal button.For example: <com.example.myapp.CustomButton android:layout_width="wrap_content" android:layout_height="wrap_content" /> In this way, you can use the SUPPORT LIBRARY to define other types of views, such as text boxes, image views, etc. Android Support Library provides a rich custom view function that can meet the unique design needs of developers.This article provides a simple example, and introduces how to use the SUPPORT LIBRARY in the Android application.I hope this article can help you start using Android Support Library for custom view development.