Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyDude1994 committed Jan 24, 2021
2 parents 56f8207 + ee5c5ad commit 692926f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions app/src/main/java/crazydude/com/telemetry/ui/TextViewOutline.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.TypedValue;

import androidx.appcompat.widget.AppCompatTextView;

Expand Down Expand Up @@ -73,10 +74,35 @@ private void setPaintToRegular() {
super.setShadowLayer(0, 0, 0, Color.TRANSPARENT);
}

private int measureDimension(int desiredSize, int measureSpec) {
int result;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);

if (specMode == MeasureSpec.EXACTLY) {
result = specSize;
} else {
result = desiredSize;
if (specMode == MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
}
}
return result;
}

public static int dpToPx(float dp, Context context) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setPaintToOutline();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

int outlineWidth = this.dpToPx(mOutlineSize, getContext());

this.setMeasuredDimension( this.measureDimension( getMeasuredWidth()+outlineWidth, widthMeasureSpec),
this.measureDimension( getMeasuredHeight()+outlineWidth, heightMeasureSpec));
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_maps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
android:text="Disconnected"
android:layout_above="@id/seekbar"
android:textColor="@android:color/white"
android:textSize="18sp" />
android:textSize="18sp"
android:gravity="center"/>

<include
android:id="@+id/bottom_layout"
Expand Down

0 comments on commit 692926f

Please sign in to comment.