Third-party Class library learning notes: Customshapeimageview Custom Shape ImageView

Source: Internet
Author: User

A third-party class library that came out two years ago, with a variety of shapes ImageView not limited to circular imageview, a must for project development

Github:https://github.com/mostafagazar/customshapeimageview

1, first of all the source code has a third-party class libraries: library

To import the library into the project first,

No, you can look at the import method: about Eclipse and idea importing library files

2, the source in the Res folder has a raw folder copied to its own project (selective replication, is some special graphics)

You can see that there's a bunch of. svg formatted files.

SVG can be considered the most hot picture file format, where the author has written us a few special graphics

If you want to customize more shapes, you can learn the following SVG

1, shape_5.svg Pentagon

2. Shape_circle_2.svg Shell shape

3. Shape_flower.svg Flower Shape

4. Shape_heart.svg Heart Shape

5, Shape_star star shape 1

6, Shape_star star shape 2

7, Shape_star star shape 3

3, the next is the use of

If we use the SVG-written shape under the raw folder as the shape of the ImageView

Then: Here is a app:svg_raw_resource= "@raw/shape_star_3" Here is the specified picture shape under the Res/raw folder which

1<Com.meg7.widget.SvgImageView2Android:layout_width="50DP"3android:layout_height="50DP"4Android:src="@drawable/hydrangeas"5App:svg_raw_resource="@raw/shape_star_3"6Android:scaletype="Centercrop"/>

Here's the point:

The actual development, the most commonly used is the circular picture, then the above several are special graphics, to use the circular imageview how to do?

Look at the class library, several source code

Baseimageview.java is the basic class

The Circleimageview.java class is a class that inherits Baseimageview.java, and is used for circular ImageView

Use: This is simple, and ordinary imageview like the use, the label has 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 part of the need.

SOURCE Customshapeimageview.java See the next source is the default display circular picture of the ImageView, there is a circle, square, custom shape, see the situation used, personal feeling, the above several use up is enough.

Related knowledge:

Custom circular Picture

Third-party Class library learning notes: Customshapeimageview Custom Shape ImageView

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.