Skip to content

Commit ab1f8b1

Browse files
committed
Setting textZoom via xml added
1 parent 611d408 commit ab1f8b1

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mathview/src/main/java/com/jstarczewski/pc/mathview/src/MathView.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ class MathView : WebView {
2828
setLayerType(View.LAYER_TYPE_HARDWARE, null)
2929
else
3030
setLayerType(View.LAYER_TYPE_SOFTWARE, null)
31-
setInitialScale(resources.displayMetrics.densityDpi)
32-
3331
if (attrs != null) {
3432
val math = context.obtainStyledAttributes(attrs, R.styleable.MathView)
35-
if (math.hasValue(R.styleable.MathView_text)) {
33+
if (math.hasValue(R.styleable.MathView_text))
3634
this.text = math.getString(R.styleable.MathView_text)
37-
}
35+
if (math.hasValue(R.styleable.MathView_textZoom))
36+
setInitialScale((resources.displayMetrics.densityDpi) / 100 * math.getInt(R.styleable.MathView_textZoom, 100))
3837
math.recycle()
3938
}
4039
}
@@ -79,5 +78,5 @@ class MathView : WebView {
7978
}
8079

8180
enum class TextAlign {
82-
CENTER, LEFT, RIGHT, JUSTIFY
81+
CENTER, START, RIGHT, JUSTIFY
8382
}

mathview/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<attr name="textColor" format="string"/> -->
88
<declare-styleable name="MathView">
99
<attr name="text" format="string"/>
10+
<attr name="textZoom" format="integer"/>
1011
</declare-styleable>
1112

1213
</resources>

0 commit comments

Comments
 (0)