修改text相关自定义属性,如:text->labelText。
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
16
README.md
16
README.md
@@ -23,11 +23,11 @@ ZXingLite for Android 是ZXing的精简版,优化扫码和生成二维码功
|
|||||||
| cornerColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区边角的颜色 |
|
| cornerColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区边角的颜色 |
|
||||||
| laserColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区激光线的颜色 |
|
| laserColor | color |<font color=#1FB3E2>#FF1FB3E2</font>| 扫描区激光线的颜色 |
|
||||||
| resultPointColor | color |<font color=#EFBD21>#C0EFBD21</font>| 扫描区结果点的颜色 |
|
| resultPointColor | color |<font color=#EFBD21>#C0EFBD21</font>| 扫描区结果点的颜色 |
|
||||||
| text | string | | 扫描提示文本信息 |
|
| labelText | string | | 扫描提示文本信息 |
|
||||||
| textColor | color |<font color=#C0C0C0>#FFC0C0C0</font>| 提示文本字体颜色 |
|
| labelTextColor | color |<font color=#C0C0C0>#FFC0C0C0</font>| 提示文本字体颜色 |
|
||||||
| textSize | dimension |14sp| 提示文本字体大小 |
|
| labelTextSize | dimension |14sp| 提示文本字体大小 |
|
||||||
| textPadding | dimension |24dp| 提示文本距离扫描区的间距 |
|
| labelTextPadding | dimension |24dp| 提示文本距离扫描区的间距 |
|
||||||
| textLocation | enum |top| 提示文本信息显示的位置 |
|
| labelTextLocation | enum |top| 提示文本信息显示的位置 |
|
||||||
|
|
||||||
## 引入
|
## 引入
|
||||||
|
|
||||||
@@ -36,17 +36,17 @@ ZXingLite for Android 是ZXing的精简版,优化扫码和生成二维码功
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.king.zxing</groupId>
|
<groupId>com.king.zxing</groupId>
|
||||||
<artifactId>zxing-lite</artifactId>
|
<artifactId>zxing-lite</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.0.4</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
### Gradle:
|
### Gradle:
|
||||||
```gradle
|
```gradle
|
||||||
implementation 'com.king.zxing:zxing-lite:1.0.3'
|
implementation 'com.king.zxing:zxing-lite:1.0.4'
|
||||||
```
|
```
|
||||||
### Lvy:
|
### Lvy:
|
||||||
```lvy
|
```lvy
|
||||||
<dependency org='com.king.zxing' name='zxing-lite' rev='1.0.3'>
|
<dependency org='com.king.zxing' name='zxing-lite' rev='1.0.4'>
|
||||||
<artifact name='$AID' ext='pom'></artifact>
|
<artifact name='$AID' ext='pom'></artifact>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
android:id="@+id/viewfinder_view"
|
android:id="@+id/viewfinder_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:text="@string/tips_scan_code"
|
app:labelText="@string/tips_scan_code"
|
||||||
app:textSize="@dimen/size_14sp"
|
app:labelTextSize="@dimen/size_14sp"
|
||||||
app:laserColor="@color/colorAccent"
|
app:laserColor="@color/colorAccent"
|
||||||
app:frameColor="@color/colorPrimary"
|
app:frameColor="@color/colorPrimary"
|
||||||
app:cornerColor="@color/colorPrimary"
|
app:cornerColor="@color/colorPrimary"
|
||||||
app:resultPointColor="@color/colorAccent"
|
app:resultPointColor="@color/colorAccent"
|
||||||
app:textLocation="bottom"/>
|
app:labelTextLocation="bottom"/>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivFlash"
|
android:id="@+id/ivFlash"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ public final class ViewfinderView extends View {
|
|||||||
private final int cornerColor;
|
private final int cornerColor;
|
||||||
private final int resultPointColor;
|
private final int resultPointColor;
|
||||||
private int scannerAlpha;
|
private int scannerAlpha;
|
||||||
private final float textPadding;
|
private final float labelTextPadding;
|
||||||
private TextLocation textLocation;
|
private TextLocation labelTextLocation;
|
||||||
//扫描区域提示文本
|
//扫描区域提示文本
|
||||||
private String labelText;
|
private String labelText;
|
||||||
//扫描区域提示文本颜色
|
//扫描区域提示文本颜色
|
||||||
@@ -86,7 +86,7 @@ public final class ViewfinderView extends View {
|
|||||||
private float labelTextSize;
|
private float labelTextSize;
|
||||||
public int scannerStart = 0;
|
public int scannerStart = 0;
|
||||||
public int scannerEnd = 0;
|
public int scannerEnd = 0;
|
||||||
private boolean isShowResultPoint;
|
private boolean isShowResultPoint = true;
|
||||||
|
|
||||||
private List<ResultPoint> possibleResultPoints;
|
private List<ResultPoint> possibleResultPoints;
|
||||||
private List<ResultPoint> lastPossibleResultPoints;
|
private List<ResultPoint> lastPossibleResultPoints;
|
||||||
@@ -126,11 +126,11 @@ public final class ViewfinderView extends View {
|
|||||||
laserColor = array.getColor(R.styleable.ViewfinderView_laserColor, ContextCompat.getColor(context,R.color.viewfinder_laser));
|
laserColor = array.getColor(R.styleable.ViewfinderView_laserColor, ContextCompat.getColor(context,R.color.viewfinder_laser));
|
||||||
resultPointColor = array.getColor(R.styleable.ViewfinderView_resultPointColor, ContextCompat.getColor(context,R.color.viewfinder_result_point_color));
|
resultPointColor = array.getColor(R.styleable.ViewfinderView_resultPointColor, ContextCompat.getColor(context,R.color.viewfinder_result_point_color));
|
||||||
|
|
||||||
labelText = array.getString(R.styleable.ViewfinderView_text);
|
labelText = array.getString(R.styleable.ViewfinderView_labelText);
|
||||||
labelTextColor = array.getColor(R.styleable.ViewfinderView_textColor, ContextCompat.getColor(context,R.color.viewfinder_text_color));
|
labelTextColor = array.getColor(R.styleable.ViewfinderView_labelTextColor, ContextCompat.getColor(context,R.color.viewfinder_text_color));
|
||||||
labelTextSize = array.getDimension(R.styleable.ViewfinderView_textSize, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,14f,getResources().getDisplayMetrics()));
|
labelTextSize = array.getDimension(R.styleable.ViewfinderView_labelTextSize, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,14f,getResources().getDisplayMetrics()));
|
||||||
textPadding = array.getDimension(R.styleable.ViewfinderView_textPadding,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,24,getResources().getDisplayMetrics()));
|
labelTextPadding = array.getDimension(R.styleable.ViewfinderView_labelTextPadding,TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,24,getResources().getDisplayMetrics()));
|
||||||
textLocation = TextLocation.getFromInt(array.getInt(R.styleable.ViewfinderView_textLocation,0));
|
labelTextLocation = TextLocation.getFromInt(array.getInt(R.styleable.ViewfinderView_labelTextLocation,0));
|
||||||
|
|
||||||
array.recycle();
|
array.recycle();
|
||||||
|
|
||||||
@@ -219,6 +219,10 @@ public final class ViewfinderView extends View {
|
|||||||
paint.setColor(resultPointColor);
|
paint.setColor(resultPointColor);
|
||||||
synchronized (currentPossible) {
|
synchronized (currentPossible) {
|
||||||
for (ResultPoint point : currentPossible) {
|
for (ResultPoint point : currentPossible) {
|
||||||
|
if(point.getX()<frame.left || point.getX()>frame.right ||
|
||||||
|
point.getY()<frame.top || point.getY()>frame.bottom){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX),
|
canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX),
|
||||||
frameTop + (int) (point.getY() * scaleY),
|
frameTop + (int) (point.getY() * scaleY),
|
||||||
POINT_SIZE, paint);
|
POINT_SIZE, paint);
|
||||||
@@ -255,11 +259,11 @@ public final class ViewfinderView extends View {
|
|||||||
textPaint.setTextSize(labelTextSize);
|
textPaint.setTextSize(labelTextSize);
|
||||||
textPaint.setTextAlign(Paint.Align.CENTER);
|
textPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
StaticLayout staticLayout = new StaticLayout(labelText,textPaint,canvas.getWidth(), Layout.Alignment.ALIGN_NORMAL,1.0f,0.0f,true);
|
StaticLayout staticLayout = new StaticLayout(labelText,textPaint,canvas.getWidth(), Layout.Alignment.ALIGN_NORMAL,1.0f,0.0f,true);
|
||||||
if(textLocation == TextLocation.BOTTOM){
|
if(labelTextLocation == TextLocation.BOTTOM){
|
||||||
canvas.translate(frame.left + frame.width() / 2,frame.bottom + textPadding);
|
canvas.translate(frame.left + frame.width() / 2,frame.bottom + labelTextPadding);
|
||||||
staticLayout.draw(canvas);
|
staticLayout.draw(canvas);
|
||||||
}else{
|
}else{
|
||||||
canvas.translate(frame.left + frame.width() / 2,frame.top - textPadding - staticLayout.getHeight());
|
canvas.translate(frame.left + frame.width() / 2,frame.top - labelTextPadding - staticLayout.getHeight());
|
||||||
staticLayout.draw(canvas);
|
staticLayout.draw(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
<attr name="cornerColor" format="color"/>
|
<attr name="cornerColor" format="color"/>
|
||||||
<attr name="laserColor" format="color"/>
|
<attr name="laserColor" format="color"/>
|
||||||
<attr name="resultPointColor" format="color"/>
|
<attr name="resultPointColor" format="color"/>
|
||||||
<attr name="text" format="string"/>
|
<attr name="labelText" format="string"/>
|
||||||
<attr name="textColor" format="color"/>
|
<attr name="labelTextColor" format="color"/>
|
||||||
<attr name="textSize" format="dimension"/>
|
<attr name="labelTextSize" format="dimension"/>
|
||||||
<attr name="textPadding" format="dimension"/>
|
<attr name="labelTextPadding" format="dimension"/>
|
||||||
<attr name="textLocation" format="enum">
|
<attr name="labelTextLocation" format="enum">
|
||||||
<enum name="top" value="0"/>
|
<enum name="top" value="0"/>
|
||||||
<enum name="bottom" value="1"/>
|
<enum name="bottom" value="1"/>
|
||||||
</attr>
|
</attr>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//App
|
//App
|
||||||
def app_version = [:]
|
def app_version = [:]
|
||||||
app_version.versionCode = 4
|
app_version.versionCode = 5
|
||||||
app_version.versionName = "1.0.3"
|
app_version.versionName = "1.0.4"
|
||||||
ext.app_version = app_version
|
ext.app_version = app_version
|
||||||
|
|
||||||
//build version
|
//build version
|
||||||
|
|||||||
Reference in New Issue
Block a user