Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Android to realize the effect of triangular frame on one side of a picture

Shulou Source: shulou.com Published: 2022-06-03 09:38:40 10月01日 Update

This article will explain in detail how to use Android to achieve the triangle border effect on one side of the picture, Xiaobian feels quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

In the real APP, we will also add a SrcollView control, so that you can continuously browse up and down. We are here mainly to let everyone understand how this view is implemented, not to demonstrate the SrcollView control under the practice, directly in the linear layout to do a simple explanation. Since there are four diagrams in the linear layout, we can write a custom view for each imageview separately, and then combine them in the syntax, which can improve the efficiency of UI development, collaborative work and development. First we implement the triangle view in the upper left corner and upper right corner.

Add the following code to the build.gradle file and import the maven library:

allprojects { repositories { ... maven { url "https://jitpack.io" } }}

Then add the library to another build.gradle file:

dependencies { implementation 'com.github.shts:TriangleLabelView:1.1.2' }

We've done our preliminary work, and now we're officially writing each of our triangle border views, starting with the first view in the upper left corner.

I. card_left_top.xml:

After writing, it will be displayed in preview as follows:

Below is the view in the upper right corner

II. card_right_top.xml:

III. card_right_buttom.xml:

IV. card_left_buttom.xml:

Finally, let's integrate it and it's OK! The code for the integrated main activity is:

V. activity_main.xml:

About "how to use Android to achieve the triangle border effect on one side of the picture" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Views triangles borders triangles articles pictures effects code upper left corner layout controls files more online work development integration good practical up and down Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Tech Info Shulou Technology OPPO Reno NVidia