This repository has been archived by the owner on Apr 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
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
胡涛
committed
Feb 13, 2017
1 parent
5bc4f9a
commit 89c1756
Showing
7 changed files
with
102 additions
and
3 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
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
56 changes: 56 additions & 0 deletions
56
library/src/main/java/com/aries/ui/view/radius/RadiusEditText.java
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,56 @@ | ||
package com.aries.ui.view.radius; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.widget.EditText; | ||
|
||
/** | ||
* Created: AriesHoo on 2017-02-13 16:10 | ||
* Function:用于需要圆角矩形框背景的EditText的情况,减少直接使用TextView时引入的shape资源文件 | ||
* Desc: | ||
*/ | ||
public class RadiusEditText extends EditText { | ||
private RadiusViewDelegate delegate; | ||
|
||
public RadiusEditText(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public RadiusEditText(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public RadiusEditText(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
delegate = new RadiusViewDelegate(this, context, attrs); | ||
} | ||
|
||
/** | ||
* use delegate to set attr | ||
*/ | ||
public RadiusViewDelegate getDelegate() { | ||
return delegate; | ||
} | ||
|
||
@Override | ||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
if (delegate.getWidthHeightEqualEnable() && getWidth() > 0 && getHeight() > 0) { | ||
int max = Math.max(getWidth(), getHeight()); | ||
int measureSpec = MeasureSpec.makeMeasureSpec(max, MeasureSpec.EXACTLY); | ||
super.onMeasure(measureSpec, measureSpec); | ||
return; | ||
} | ||
|
||
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | ||
} | ||
|
||
@Override | ||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { | ||
super.onLayout(changed, left, top, right, bottom); | ||
if (delegate.getRadiusHalfHeightEnable()) { | ||
delegate.setRadius(getHeight() / 2); | ||
} else { | ||
delegate.setBgSelector(); | ||
} | ||
} | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.