Third-party class library learning notes: CustomShapeImageView custom shape ImageView, custom imageview

Source: Internet
Author: User

Third-party class library learning notes: CustomShapeImageView custom shape ImageView, custom imageview

A third-party class library that came out two years ago. It has multiple shapes, not limited to circular ImageView, and is required for project development.

Github: https://github.com/MostafaGazar/CustomShapeImageView

 

1. First, there is a third-party class library in the source code: library

First, import the Library to the project,

If not, you can see the import method: Steps for importing library files from Eclipse and IDEA

2. In the source code, there is a raw folder under the res folder to be copied to your project (selective copying is a special image)

We can see that there are a bunch of. svg files.

SVG can be regarded as the most popular image file format at present. The author has already written several special images for us.

If you want to customize more shapes, you can learn about SVG.

1. shape_5.svg Pentagon

2. shape_circle_2.svg Shell

3. shape_flower.svg

4. shape_heart.svg heart-shaped

5. shape_star 1

6. shape_star 2

7. shape_star 3

 

3. Use

If we use the shape written by svg in the raw folder as the shape of ImageView

Then: Here is an app: svg_raw_resource = "@ raw/shape_star_3" which specifies the image in the res/raw folder

1 <com.meg7.widget.SvgImageView2 android:layout_width="50dp"3 android:layout_height="50dp"4 android:src="@drawable/hydrangeas"5 app:svg_raw_resource="@raw/shape_star_3"6 android:scaleType="centerCrop" />

Key points:

In actual development, the most common method is circular images. The above are all special images. What should I do if I want to use circular ImageView?

Look at the class library, several source code

BaseImageView. java is a basic class

While the CircleImageView. java class inherits BaseImageView. java class, which is used for circular ImageView

Use: This is simple. It is used like ordinary ImageView, And the label is changed.

1 <com.meg7.widget.CircleImageView2 android:layout_width="100dp"3 android:layout_height="100dp"4 android:src="@drawable/hydrangeas"5 android:scaleType="centerCrop" />

Rectangular ImageView: RectangleImageView. java

1 <com.meg7.widget.RectangleImageView2 android:layout_width="100dp"3 android:layout_height="100dp"4 android:src="@drawable/hydrangeas"5 android:scaleType="centerCrop" />

The above is the main requirement.

In the source code, CustomShapeImageView. java looked at the source code is to display the ImageView of the circular image by default, which contains a circle, square, custom shape, see the use of the situation, personal feeling, the above is enough to use.

Related Knowledge:

Custom circular image

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.