Skip to content

Commit

Permalink
1,修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Apr 11, 2023
1 parent 9c91cfa commit 407a98d
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 6 deletions.
13 changes: 12 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@

<com.flyjingfish.gradienttextviewlib.GradientTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="28dp"
android:layout_margin="10dp"
android:text="Hello World!"
android:textColor="@color/white"
android:textSize="30sp"
android:paddingHorizontal="10dp"
android:drawableStart="@mipmap/ic_launcher_round"
android:shadowColor="#14000000"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="3.0"
android:drawablePadding="10dp"
app:autoSizeMaxTextSize="19sp"
app:autoSizeMinTextSize="6dp"
app:autoSizeStepGranularity="1sp"
app:autoSizeTextType="uniform"
app:gradient_angle="0"
app:gradient_endColor="@color/purple_200"
app:gradient_startColor="@color/teal_200" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
import android.util.AttributeSet;
import android.util.LayoutDirection;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.text.TextUtilsCompat;

import com.flyjingfish.perfecttextviewlib.PerfectTextView;
Expand All @@ -25,7 +23,7 @@

public class GradientTextView extends PerfectTextView {

private final TextView backGroundText;
private final PerfectTextView backGroundText;
private int strokeWidth;
private int[] gradientStrokeColors;
private float[] gradientStrokePositions;
Expand Down Expand Up @@ -53,7 +51,7 @@ public GradientTextView(Context context, AttributeSet attrs,
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
isRtl = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == LayoutDirection.RTL;
}
backGroundText = new AppCompatTextView(context, attrs, defStyle);
backGroundText = new PerfectTextView(context, attrs, defStyle);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.GradientTextView);
strokeWidth = typedArray.getDimensionPixelSize(R.styleable.GradientTextView_gradient_stroke_strokeWidth, 0);
int startStrokeColor = typedArray.getColor(R.styleable.GradientTextView_gradient_stroke_startColor, 0);
Expand Down Expand Up @@ -102,7 +100,7 @@ public GradientTextView(Context context, AttributeSet attrs,

initCompoundDrawables();

backGroundText.setCompoundDrawablePadding(getCompoundDrawablePadding());

}


Expand Down Expand Up @@ -389,6 +387,192 @@ private void initCompoundDrawables(){
}

backGroundText.setCompoundDrawables(drawableLeft,drawableTop,drawableRight,drawableBottom);
backGroundText.setDrawableStartPadding(getDrawableStartPadding());
backGroundText.setDrawableEndPadding(getDrawableEndPadding());
backGroundText.setDrawableLeftPadding(getDrawableLeftPadding());
backGroundText.setDrawableRightPadding(getDrawableRightPadding());
backGroundText.setDrawableTopPadding(getDrawableTopPadding());
backGroundText.setDrawableBottomPadding(getDrawableBottomPadding());
}

@Override
public void setDrawableStart(int drawableStart) {
backGroundText.setDrawableStart(drawableStart);
super.setDrawableStart(drawableStart);
}

@Override
public void setDrawableEnd(int drawableEnd) {
backGroundText.setDrawableEnd(drawableEnd);
super.setDrawableEnd(drawableEnd);
}

@Override
public void setDrawableTop(int drawableTop) {
backGroundText.setDrawableTop(drawableTop);
super.setDrawableTop(drawableTop);
}

@Override
public void setDrawableBottom(int drawableBottom) {
backGroundText.setDrawableBottom(drawableBottom);
super.setDrawableBottom(drawableBottom);
}

@Override
public void setDrawableLeft(int drawableLeft) {
backGroundText.setDrawableLeft(drawableLeft);
super.setDrawableLeft(drawableLeft);
}

@Override
public void setDrawableRight(int drawableRight) {
backGroundText.setDrawableRight(drawableRight);
super.setDrawableRight(drawableRight);
}

@Override
public void setDrawableStart(Drawable drawableStart) {
backGroundText.setDrawableStart(drawableStart);
super.setDrawableStart(drawableStart);
}

@Override
public void setDrawableEnd(Drawable drawableEnd) {
backGroundText.setDrawableEnd(drawableEnd);
super.setDrawableEnd(drawableEnd);
}

@Override
public void setDrawableLeft(Drawable drawableLeft) {
backGroundText.setDrawableLeft(drawableLeft);
super.setDrawableLeft(drawableLeft);
}

@Override
public void setDrawableRight(Drawable drawableRight) {
backGroundText.setDrawableRight(drawableRight);
super.setDrawableRight(drawableRight);
}

@Override
public void setDrawableTop(Drawable drawableTop) {
backGroundText.setDrawableTop(drawableTop);
super.setDrawableTop(drawableTop);
}

@Override
public void setDrawableBottom(Drawable drawableBottom) {
backGroundText.setDrawableBottom(drawableBottom);
super.setDrawableBottom(drawableBottom);
}


@Override
public void setSelectedText(CharSequence selectedText) {
backGroundText.setSelectedText(selectedText);
super.setSelectedText(selectedText);
}

@Override
public void setSelectedText(int resid) {
backGroundText.setSelectedText(resid);
super.setSelectedText(resid);
}

@Override
public void setDefaultHint(CharSequence defaultHint) {
backGroundText.setDefaultHint(defaultHint);
super.setDefaultHint(defaultHint);
}

@Override
public void setSelectedHint(CharSequence selectedHint) {
backGroundText.setSelectedHint(selectedHint);
super.setSelectedHint(selectedHint);
}

@Override
public void setDefaultHint(int resid) {
backGroundText.setDefaultHint(resid);
super.setDefaultHint(resid);
}

@Override
public void setSelectedHint(int resid) {
backGroundText.setSelectedHint(resid);
super.setSelectedHint(resid);
}

@Override
public void setDrawableStartWidthHeight(int width, int height) {
backGroundText.setDrawableStartWidthHeight(width, height);
super.setDrawableStartWidthHeight(width, height);
}

@Override
public void setDrawableTopWidthHeight(int width, int height) {
backGroundText.setDrawableTopWidthHeight(width, height);
super.setDrawableTopWidthHeight(width, height);
}

@Override
public void setDrawableEndWidthHeight(int width, int height) {
backGroundText.setDrawableEndWidthHeight(width, height);
super.setDrawableEndWidthHeight(width, height);
}

@Override
public void setDrawableBottomWidthHeight(int width, int height) {
backGroundText.setDrawableBottomWidthHeight(width, height);
super.setDrawableBottomWidthHeight(width, height);
}

@Override
public void setDrawableLeftWidthHeight(int width, int height) {
backGroundText.setDrawableLeftWidthHeight(width, height);
super.setDrawableLeftWidthHeight(width, height);
}

@Override
public void setDrawableRightWidthHeight(int width, int height) {
backGroundText.setDrawableRightWidthHeight(width, height);
super.setDrawableRightWidthHeight(width, height);
}

@Override
public void setDrawableStartPadding(int drawableStartPadding) {
backGroundText.setDrawableStartPadding(drawableStartPadding);
super.setDrawableStartPadding(drawableStartPadding);
}

@Override
public void setDrawableTopPadding(int drawableTopPadding) {
backGroundText.setDrawableTopPadding(drawableTopPadding);
super.setDrawableTopPadding(drawableTopPadding);
}

@Override
public void setDrawableEndPadding(int drawableEndPadding) {
backGroundText.setDrawableEndPadding(drawableEndPadding);
super.setDrawableEndPadding(drawableEndPadding);
}

@Override
public void setDrawableBottomPadding(int drawableBottomPadding) {
backGroundText.setDrawableBottomPadding(drawableBottomPadding);
super.setDrawableBottomPadding(drawableBottomPadding);
}

@Override
public void setDrawableLeftPadding(int drawableLeftPadding) {
backGroundText.setDrawableLeftPadding(drawableLeftPadding);
super.setDrawableLeftPadding(drawableLeftPadding);
}

@Override
public void setDrawableRightPadding(int drawableRightPadding) {
backGroundText.setDrawableRightPadding(drawableRightPadding);
super.setDrawableRightPadding(drawableRightPadding);
}
}

0 comments on commit 407a98d

Please sign in to comment.