Skip to content

Commit

Permalink
添加代码设置属性功能
Browse files Browse the repository at this point in the history
  • Loading branch information
KuangGang committed Dec 24, 2019
1 parent ca61c50 commit 33498ce
Show file tree
Hide file tree
Showing 14 changed files with 801 additions and 35 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/com/kproduce/roundcorners/test/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.kproduce.roundcorners.RoundTextView;

/**
* @author kuanggang on 2019/12/01
Expand All @@ -13,5 +16,14 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final RoundTextView tv = findViewById(R.id.tv);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv.setRadius(50, 0, 0, 0);
tv.setStrokeWidthColor(20, getResources().getColor(android.R.color.holo_green_dark));
}
});
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
android:textSize="16sp" />

<com.kproduce.roundcorners.RoundTextView
android:id="@+id/tv"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_marginTop="40dp"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ buildscript {

min_sdk_version = 16
target_sdk_version = 28
version_code = 3
version_name = '1.0.2'
version_code = 4
version_name = '1.0.3'
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

import com.kproduce.roundcorners.util.RoundHelper;
import com.kproduce.roundcorners.util.RoundMethodInterface;

/**
* @author kuanggang on 2019/12/10
*/
public class CircleImageView extends AppCompatImageView {
public class CircleImageView extends AppCompatImageView implements RoundMethodInterface {

private RoundHelper mHelper = new RoundHelper();

Expand Down Expand Up @@ -39,4 +42,68 @@ public void draw(Canvas canvas) {
mHelper.drawPath(canvas);
}

@Override
public void setRadius(int radius) {
mHelper.setRadius(radius);
}

@Override
public void setRadius(int radiusTopLeft, int radiusTopRight, int radiusBottomLeft, int radiusBottomRight) {
mHelper.setRadius(radiusTopLeft, radiusTopRight, radiusBottomLeft, radiusBottomRight);
}

@Override
public void setRadiusLeft(int radius) {
mHelper.setRadiusLeft(radius);
}

@Override
public void setRadiusRight(int radius) {
mHelper.setRadiusRight(radius);
}

@Override
public void setRadiusTop(int radius) {
mHelper.setRadiusTop(radius);
}

@Override
public void setRadiusBottom(int radius) {
mHelper.setRadiusBottom(radius);
}

@Override
public void setRadiusTopLeft(int radius) {
mHelper.setRadiusTopLeft(radius);
}

@Override
public void setRadiusTopRight(int radius) {
mHelper.setRadiusTopRight(radius);
}

@Override
public void setRadiusBottomLeft(int radius) {
mHelper.setRadiusBottomLeft(radius);
}

@Override
public void setRadiusBottomRight(int radius) {
mHelper.setRadiusBottomRight(radius);
}

@Override
public void setStrokeWidth(int width) {
mHelper.setStrokeWidth(width);
}

@Override
public void setStrokeColor(int color) {
mHelper.setStrokeColor(color);
}

@Override
public void setStrokeWidthColor(int width, int color) {
mHelper.setStrokeWidthColor(width, color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import android.support.v7.widget.AppCompatButton;
import android.util.AttributeSet;

import com.kproduce.roundcorners.util.RoundHelper;
import com.kproduce.roundcorners.util.RoundMethodInterface;

/**
* @author kuanggang on 2019/12/10
*/
public class RoundButton extends AppCompatButton {
public class RoundButton extends AppCompatButton implements RoundMethodInterface {

private RoundHelper mHelper = new RoundHelper();

Expand Down Expand Up @@ -38,4 +41,68 @@ public void draw(Canvas canvas) {
mHelper.drawPath(canvas);
}

@Override
public void setRadius(int radius) {
mHelper.setRadius(radius);
}

@Override
public void setRadius(int radiusTopLeft, int radiusTopRight, int radiusBottomLeft, int radiusBottomRight) {
mHelper.setRadius(radiusTopLeft, radiusTopRight, radiusBottomLeft, radiusBottomRight);
}

@Override
public void setRadiusLeft(int radius) {
mHelper.setRadiusLeft(radius);
}

@Override
public void setRadiusRight(int radius) {
mHelper.setRadiusRight(radius);
}

@Override
public void setRadiusTop(int radius) {
mHelper.setRadiusTop(radius);
}

@Override
public void setRadiusBottom(int radius) {
mHelper.setRadiusBottom(radius);
}

@Override
public void setRadiusTopLeft(int radius) {
mHelper.setRadiusTopLeft(radius);
}

@Override
public void setRadiusTopRight(int radius) {
mHelper.setRadiusTopRight(radius);
}

@Override
public void setRadiusBottomLeft(int radius) {
mHelper.setRadiusBottomLeft(radius);
}

@Override
public void setRadiusBottomRight(int radius) {
mHelper.setRadiusBottomRight(radius);
}

@Override
public void setStrokeWidth(int width) {
mHelper.setStrokeWidth(width);
}

@Override
public void setStrokeColor(int color) {
mHelper.setStrokeColor(color);
}

@Override
public void setStrokeWidthColor(int width, int color) {
mHelper.setStrokeWidthColor(width, color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import android.content.Context;
import android.graphics.Canvas;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import com.kproduce.roundcorners.util.RoundHelper;
import com.kproduce.roundcorners.util.RoundMethodInterface;

/**
* @author kuanggang on 2019/12/10
*/
public class RoundFrameLayout extends FrameLayout {
public class RoundFrameLayout extends FrameLayout implements RoundMethodInterface {

private RoundHelper mHelper = new RoundHelper();

Expand Down Expand Up @@ -38,4 +40,69 @@ public void draw(Canvas canvas) {
super.draw(canvas);
mHelper.drawPath(canvas);
}

@Override
public void setRadius(int radius) {
mHelper.setRadius(radius);
}

@Override
public void setRadius(int radiusTopLeft, int radiusTopRight, int radiusBottomLeft, int radiusBottomRight) {
mHelper.setRadius(radiusTopLeft, radiusTopRight, radiusBottomLeft, radiusBottomRight);
}

@Override
public void setRadiusLeft(int radius) {
mHelper.setRadiusLeft(radius);
}

@Override
public void setRadiusRight(int radius) {
mHelper.setRadiusRight(radius);
}

@Override
public void setRadiusTop(int radius) {
mHelper.setRadiusTop(radius);
}

@Override
public void setRadiusBottom(int radius) {
mHelper.setRadiusBottom(radius);
}

@Override
public void setRadiusTopLeft(int radius) {
mHelper.setRadiusTopLeft(radius);
}

@Override
public void setRadiusTopRight(int radius) {
mHelper.setRadiusTopRight(radius);
}

@Override
public void setRadiusBottomLeft(int radius) {
mHelper.setRadiusBottomLeft(radius);
}

@Override
public void setRadiusBottomRight(int radius) {
mHelper.setRadiusBottomRight(radius);
}

@Override
public void setStrokeWidth(int width) {
mHelper.setStrokeWidth(width);
}

@Override
public void setStrokeColor(int color) {
mHelper.setStrokeColor(color);
}

@Override
public void setStrokeWidthColor(int width, int color) {
mHelper.setStrokeWidthColor(width, color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

import com.kproduce.roundcorners.util.RoundHelper;
import com.kproduce.roundcorners.util.RoundMethodInterface;

/**
* @author kuanggang on 2019/12/10
*/
public class RoundImageView extends AppCompatImageView {
public class RoundImageView extends AppCompatImageView implements RoundMethodInterface {

private RoundHelper mHelper = new RoundHelper();

Expand Down Expand Up @@ -38,4 +41,68 @@ public void draw(Canvas canvas) {
mHelper.drawPath(canvas);
}

@Override
public void setRadius(int radius) {
mHelper.setRadius(radius);
}

@Override
public void setRadius(int radiusTopLeft, int radiusTopRight, int radiusBottomLeft, int radiusBottomRight) {
mHelper.setRadius(radiusTopLeft, radiusTopRight, radiusBottomLeft, radiusBottomRight);
}

@Override
public void setRadiusLeft(int radius) {
mHelper.setRadiusLeft(radius);
}

@Override
public void setRadiusRight(int radius) {
mHelper.setRadiusRight(radius);
}

@Override
public void setRadiusTop(int radius) {
mHelper.setRadiusTop(radius);
}

@Override
public void setRadiusBottom(int radius) {
mHelper.setRadiusBottom(radius);
}

@Override
public void setRadiusTopLeft(int radius) {
mHelper.setRadiusTopLeft(radius);
}

@Override
public void setRadiusTopRight(int radius) {
mHelper.setRadiusTopRight(radius);
}

@Override
public void setRadiusBottomLeft(int radius) {
mHelper.setRadiusBottomLeft(radius);
}

@Override
public void setRadiusBottomRight(int radius) {
mHelper.setRadiusBottomRight(radius);
}

@Override
public void setStrokeWidth(int width) {
mHelper.setStrokeWidth(width);
}

@Override
public void setStrokeColor(int color) {
mHelper.setStrokeColor(color);
}

@Override
public void setStrokeWidthColor(int width, int color) {
mHelper.setStrokeWidthColor(width, color);
}
}
Loading

0 comments on commit 33498ce

Please sign in to comment.