AvatarImageView


Source link: https://github.com/Carbs0126/AvatarImageView

AvatarImageView

![Android Arsenal][1]

#??? ???????????????????????????????????????????????????????????????????????????????????????????????????????1????clip?????????????clip??

##???

![1.0.2??clip????][2] ![?????????][3] ![????][5]

##?????

compile 'cn.carbs.android:AvatarImageView:1.0.4'

##?????

  1. ???????
  2. ???????
  3. ?????????????????
  4. ?????????
  5. ????????????????????????????????????????????????????????????????????????????
  6. ??????ImageView???onDraw()????super.onDraw()???????drawable????????????view?????Glide??????????????????????????????;
  7. ??padding?
  8. ????????clip??
  9. ?????clip???????maskratio??????????

##????? ###1.0.4

  1. ??rx? ###1.0.3
  2. ?????????SquareAvatarImageView?????????? ###1.0.2
  3. ???????clip??

##????? ?????wrap_content??

##????????? ??shader + matrix????????????????shader??????????????matrix????

##????? (1)????????????

AvatarImageView aiv = (AvatarImageView) this.findViewById(R.id.aiv);
 //????? aiv.setImageResource(R.drawable.id_014);
 //??? aiv.setDrawable(drawable);
 //??? aiv.setBitmap(bitmap);
 //??? aiv.setImageDrawable(drawable);
 //????? aiv.setTextAndColor("?", AvatarImageView.COLORS[0]);
//????????????????????????clip?????????clip?? //??? aiv.setTextAndColorSeed("?","??");
//“??”??????backgroundcolor?seed

(2)?Glide????

Glide
  .with(activity)
  .load(picurl)
  .centerCrop()
  .crossFade()
  .into(aiv);

##????? 1.????

compile 'cn.carbs.android:AvatarImageView:1.0.3'

2.layout??????view

<cn.carbs.android.avatarimageview.library.AvatarImageView

 android:id="@+id/item_avatar"

 android:layout_width="60dp"

 android:layout_height="60dp"

 android:padding="5dp"

 app:aiv_BoarderWidth="2dp"//????

 app:aiv_ShowBoarder="false"//??????

 app:aiv_TextSizeRatio="0.4"/>//??????????????

##?? ####[CircleImageView][4]

#English

##Abstract AvatarImageView on Android platform can display circle text or circle image

##Screenshot

![load local image resources][2] ![load local image resources][3]

##Main features:

  1. show circle image(including bitmap and drawable);
  2. show circle text(can generate a colorful background for text);
  3. the textsize can be modified according to the ratio of AvatarImageView's width;
  4. can add a circle boarder for text or image, and the boarder can be adjusted in stroke width or color;
  5. the image or text is aways in the center; the rule is : if the image's width is larger than height, then get the center square of the image, with the same length side of image's width. vice versa.
  6. since AvatarImageView extends from ImageView, and remove super.onDraw(), and override setImageResoure() setImageDrawable(), then we can use Glide or other famouse Loading Image Libary to load image into AvatarImageView conveniently.
  7. surpport padding;
  8. have clip effect if the text's length > 1
  9. can set the clip effect's amplify ratio by setting mask ratio

##Attention not support wrap_content pattern temporarily

##How to use it: (1)How to set image or text

AvatarImageView aiv = (AvatarImageView) this.findViewById(R.id.aiv);
 //set image? aiv.setImageResource(R.drawable.id_014);
 //or? aiv.setDrawable(drawable);
 //or? aiv.setBitmap(bitmap);
 //or? aiv.setImageDrawable(drawable);
 //set text: aiv.setTextAndColor("Android", AvatarImageView.COLORS[0]);
//set backgroundcolor directly, if the text's length > 1, will have clip effect //or aiv.setTextAndColorSeed("Android","Android platform");
//"Android platform" as the backgroundcolor seed

(2)use with Glide:

Glide
  .with(activity)
  .load(picurl)
  .centerCrop()
  .crossFade()
  .into(aiv);

##add to your project 1.add dependence

compile 'cn.carbs.android:AvatarImageView:1.0.4'

2.add into xml layout file

<cn.carbs.android.avatarimageview.library.AvatarImageView

 android:id="@+id/item_avatar"

 android:layout_width="60dp"

 android:layout_height="60dp"

 android:padding="5dp"

 app:aiv_BoarderWidth="2dp"//

 app:aiv_ShowBoarder="false"//

 app:aiv_TextSizeRatio="0.4"/>//equals textsize divides circle diameter

##Thanks ####[CircleImageView][4]

License

Copyright 2016 Carbs.Wang (AvatarImageView)  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

[1]: https://img.shields.io/badge/Android%20Arsenal-AvatarImageView-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/3820 [2]: https://github.com/Carbs0126/Screenshot/blob/master/avatar_image_view_3_in_1.jpg [3]: https://github.com/Carbs0126/Screenshot/blob/master/avatar_image_view_2_in_1.jpg [4]: https://github.com/hdodenhof/CircleImageView [5]: https://github.com/Carbs0126/Screenshot/blob/master/SquareAvatarImageView.png

Resources

Easily notify a user with a simple alert, inform them of an optional update, and in dire situations block the user from accessing older versions of the application completely.

A Gradle plugin that helps facilitate Github PR checking and automatic commenting of violations.

Leanback cards is a Widget library for use with Android TV applications. It provides an extended set of customisable content cards to enhance your User Interfaces.

This project aims at creating an animation library for different types of loading animations, progress dialogs, etc.

FromTo is a helper library that makes it simple to handle asynchronous actions with views for Android and Java/Kotlin.

Animated icons implemented using AnimatedVectorDrawable.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes