-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c39b105
Showing
16 changed files
with
648 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
*.iml | ||
*.bat | ||
*.zip | ||
local.properties | ||
*.hprof | ||
/captures | ||
~$* | ||
gradlew | ||
.DS_Store | ||
.gradle | ||
build | ||
/*/build | ||
proguardMapping.txt | ||
|
||
#.idea相关 | ||
/.idea | ||
.externalNativeBuild | ||
.cxx | ||
|
||
# 安装包 | ||
/debug | ||
/release | ||
/*/debug | ||
/*/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Lightweight and fast RoundedImageView | ||
|
||
### [中文文档](README-zh.md) | ||
|
||
``` | ||
<com.wang.round.RoundedImageView | ||
android:id="@+id/riv" | ||
android:layout_width="400dp" | ||
android:layout_height="200dp" | ||
android:layout_marginTop="1px" | ||
android:background="#aaa" | ||
android:padding="20dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/ttt3" | ||
app:borderColor="#f0f" | ||
app:borderWidth="10dp" | ||
app:cornerRadius="50dp" /> | ||
``` | ||
|
||
![img](example.png "img") | ||
|
||
#### All attributes: | ||
|
||
cornerRadius、cornerTopLeftRadius、cornerTopRightRadius、cornerBottomLeftRadius、cornerBottomRightRadius、oval | ||
|
||
borderWidth、borderColor | ||
|
||
### Support | ||
|
||
- Support rounded corners, four different rounded corners, oval, and border | ||
|
||
- Support xml preview | ||
|
||
- All ImageView images are supported, such as: glide load gif images | ||
|
||
- All ImageView properties are available and are exactly the same (except setCropToPadding), such as | ||
adjustViewBounds、scaleType、padding | ||
|
||
### Gradle | ||
|
||
Your build.gradle must have jitpack.io, like: | ||
|
||
``` | ||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
google() | ||
jcenter() | ||
} | ||
} | ||
``` | ||
|
||
then: | ||
`api or implementation 'com.github.weimingjue::'` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
|
||
defaultConfig { | ||
applicationId "com.wang.example" | ||
minSdkVersion 16 | ||
|
||
resValue("string", "app_name", "圆角iv示例") | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
implementation 'androidx.core:core-ktx:1.3.2' | ||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.3.0' | ||
|
||
implementation 'com.github.bumptech.glide:glide:4.9.0' | ||
|
||
implementation project(path: ':round') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.wang.example"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Design.Light.NoActionBar"> | ||
<activity android:name="com.wang.example.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.wang.example | ||
|
||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.os.Message | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.bumptech.glide.Glide | ||
import com.wang.round.RoundedImageView | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
val riv = findViewById<RoundedImageView>(R.id.riv_0) | ||
object : Handler(Looper.getMainLooper()) { | ||
override fun handleMessage(msg: Message) { | ||
super.handleMessage(msg) | ||
if (isFinishing) { | ||
return | ||
} | ||
toast("切换${msg.what}") | ||
riv.run { | ||
when (msg.what) { | ||
1 -> { | ||
setCornerRadius(60) | ||
} | ||
2 -> { | ||
setCornerRadius(150, 150, 60, 150) | ||
setBorderWidth(9) | ||
setBorderColor(0xff0000ff.toInt()) | ||
} | ||
3 -> { | ||
setCornerRadius(10000) | ||
setBorderWidth(0) | ||
} | ||
4 -> { | ||
setIsOval(true) | ||
setBorderWidth(9) | ||
setBorderColor(0xff0000ff.toInt()) | ||
} | ||
5 -> { | ||
Glide.with(this) | ||
.asGif() | ||
.load(R.drawable.gif_test) | ||
.into(this) | ||
} | ||
else -> { | ||
} | ||
} | ||
} | ||
if (msg.what < 5) { | ||
sendEmptyMessageDelayed(msg.what + 1, 2000); | ||
} | ||
} | ||
}.sendEmptyMessageDelayed(1, 2000) | ||
} | ||
|
||
fun toast(st: String) { | ||
Toast.makeText(this, st, Toast.LENGTH_SHORT).show() | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<com.wang.round.RoundedImageView | ||
android:id="@+id/riv_0" | ||
android:layout_width="200dp" | ||
android:layout_height="100dp" | ||
android:background="#eee" | ||
android:padding="10dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_test" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.wang.round.RoundedImageView | ||
android:layout_width="200dp" | ||
android:layout_height="100dp" | ||
android:background="#ddd" | ||
android:padding="10dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_test" | ||
app:cornerRadius="20dp" | ||
app:layout_constraintLeft_toRightOf="@+id/riv_0" | ||
app:layout_constraintTop_toTopOf="@+id/riv_0" /> | ||
|
||
<com.wang.round.RoundedImageView | ||
android:id="@+id/riv_2" | ||
android:layout_width="200dp" | ||
android:layout_height="100dp" | ||
android:background="#ccc" | ||
android:padding="10dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_test" | ||
app:borderColor="#00f" | ||
app:borderWidth="3dp" | ||
app:cornerBottomLeftRadius="20dp" | ||
app:cornerRadius="50dp" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/riv_0" /> | ||
|
||
<com.wang.round.RoundedImageView | ||
android:layout_width="200dp" | ||
android:layout_height="100dp" | ||
android:background="#bbb" | ||
android:padding="10dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_test" | ||
app:cornerRadius="5000dp" | ||
app:layout_constraintLeft_toRightOf="@+id/riv_2" | ||
app:layout_constraintTop_toTopOf="@+id/riv_2" /> | ||
|
||
<com.wang.round.RoundedImageView | ||
android:id="@+id/riv_4" | ||
android:layout_width="200dp" | ||
android:layout_height="100dp" | ||
android:background="#aaa" | ||
android:padding="10dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_test" | ||
app:borderColor="#00f" | ||
app:borderWidth="3dp" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/riv_2" | ||
app:oval="true" /> | ||
|
||
<com.wang.round.RoundedImageView | ||
android:layout_width="100dp" | ||
android:layout_height="100dp" | ||
android:background="#999" | ||
android:padding="10dp" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_test" | ||
app:borderColor="#00f" | ||
app:borderWidth="3dp" | ||
app:layout_constraintLeft_toRightOf="@+id/riv_4" | ||
app:layout_constraintTop_toTopOf="@+id/riv_4" | ||
app:oval="true" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
ext.kotlin_version = "1.4.32" | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
google() | ||
jcenter() | ||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } | ||
maven { url 'https://maven.aliyun.com/repository/public/' } | ||
maven { url 'https://maven.aliyun.com/repository/google/' } | ||
maven { url 'https://maven.aliyun.com/repository/jcenter/' } | ||
maven { url 'https://maven.aliyun.com/repository/central/' } | ||
} | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:4.1.3" | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
google() | ||
jcenter() | ||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } | ||
maven { url 'https://maven.aliyun.com/repository/public/' } | ||
maven { url 'https://maven.aliyun.com/repository/google/' } | ||
maven { url 'https://maven.aliyun.com/repository/jcenter/' } | ||
maven { url 'https://maven.aliyun.com/repository/central/' } | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app"s APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
android.useAndroidX=true | ||
# Automatically convert third-party libraries to use AndroidX | ||
android.enableJetifier=true | ||
# Kotlin code style for this project: "official" or "obsolete": | ||
kotlin.code.style=official |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Tue Apr 27 15:19:57 CST 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip |
Oops, something went wrong.