Skip to content

Commit

Permalink
[ +] feat: 增加 RCSLayout 库
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsanning committed Oct 17, 2022
1 parent be079c4 commit f327e55
Show file tree
Hide file tree
Showing 15 changed files with 536 additions and 7 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
# RCSLayout

[![](https://jitpack.io/v/yangsanning/RCSLayout.svg)](https://jitpack.io/#yangsanning/RCSLayout)
[![API](https://img.shields.io/badge/API-21%2B-orange.svg?style=flat)](https://android-arsenal.com/api?level=21)

## 效果预览

| RCSLayout |
| -------------------------------------------- |
| <img src="images/image1.jpg" height="512" /> |



## 属性([Attributes](https://github.com/yangsanning/RCSLayout/blob/master/rcslayout/src/main/res/values/attr_rcs.xml))



## 添加方法

### 添加仓库

在项目的 `build.gradle` 文件中配置仓库地址。

```android
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

#### 添加项目依赖

在需要添加依赖的 Module 下添加以下信息,使用方式和普通的远程仓库一样。

```android
implementation 'com.github.yangsanning:RCSLayout:1.0.0'
```
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ android {

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

implementation project(':rcslayout')

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/wot/demo/rcslayout/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package wot.demo.rcslayout

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import wot.view.rcslayout.R
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
43 changes: 40 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,50 @@
android:layout_height="match_parent"
tools:context="wot.demo.rcslayout.MainActivity">

<TextView
<wot.view.rcslayout.RCSLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:rcs_circle="true"
app:rcs_shadowColor="#99000000"
app:rcs_shadowSize="10dp">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/wot"
tools:ignore="ContentDescription" />
</wot.view.rcslayout.RCSLayout>

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />

<wot.view.rcslayout.RCSLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="@id/guideline"
app:rcs_clip="20dp"
app:rcs_corner="20dp"
app:rcs_shadowColor="#99ff0000"
app:rcs_shadowSize="20dp">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/wot"
tools:ignore="ContentDescription" />
</wot.view.rcslayout.RCSLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Binary file added app/src/main/res/mipmap-xxhdpi/wot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions rcslayout/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
33 changes: 33 additions & 0 deletions rcslayout/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdk 32

defaultConfig {
minSdk 21
targetSdk 32

consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}
Empty file added rcslayout/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions rcslayout/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
5 changes: 5 additions & 0 deletions rcslayout/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="wot.view.rcslayout">

</manifest>
Loading

0 comments on commit f327e55

Please # to comment.