浏览代码

Update TextBox preview textview when seekbar value changes

cooperku_kdanmobile 5 年之前
父节点
当前提交
761cb246c6

+ 13 - 0
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxStyleView.kt

@@ -4,6 +4,7 @@ import android.content.Context
 import android.graphics.Typeface
 import android.util.AttributeSet
 import android.view.LayoutInflater
+import android.widget.SeekBar
 import com.kdanmobile.reader.R
 import com.kdanmobile.reader.screen.view.ColorSelectView
 import kotlinx.android.synthetic.main.view_media_box_tab_text_box_style.view.*
@@ -47,6 +48,18 @@ class TextBoxStyleView : TextBoxTabView {
             }
         }
 
+        seekBar_textBox_textSize.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
+            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
+                tv_preview.textSize = progress.toFloat()
+            }
+
+            override fun onStartTrackingTouch(seekBar: SeekBar) {
+            }
+
+            override fun onStopTrackingTouch(seekBar: SeekBar) {
+            }
+        }
+
         colorChooser_textBox.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
             override fun onColorSelected(color: Int) {
                 tv_preview.setTextColor(color)

+ 13 - 0
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxTabView.kt

@@ -5,6 +5,7 @@ import android.graphics.Typeface
 import android.support.constraint.ConstraintLayout
 import android.util.AttributeSet
 import android.view.LayoutInflater
+import android.widget.SeekBar
 import com.kdanmobile.reader.R
 import com.kdanmobile.reader.screen.data.TextBoxAttribute
 import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
@@ -62,6 +63,18 @@ open class TextBoxTabView : ConstraintLayout {
             }
         }
 
+        seekBar_textBox_textSize.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
+            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
+                tv_preview.textSize = progress.toFloat()
+            }
+
+            override fun onStartTrackingTouch(seekBar: SeekBar) {
+            }
+
+            override fun onStopTrackingTouch(seekBar: SeekBar) {
+            }
+        }
+
         colorChooser_textBox.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
             override fun onColorSelected(color: Int) {
                 tv_preview.setTextColor(color)

+ 2 - 0
reader/src/main/res/layout/view_media_box_tab_text_box.xml

@@ -39,6 +39,8 @@
             android:layout_marginRight="16dp"
             android:layout_marginEnd="16dp"
             android:gravity="center_vertical"
+            android:singleLine="true"
+            android:ellipsize="none"
             android:textColor="#f5a623"
             android:textSize="24sp"
             android:text="@string/mediaBox_textBox_simpleText" />

+ 2 - 0
reader/src/main/res/layout/view_media_box_tab_text_box_style.xml

@@ -39,6 +39,8 @@
             android:layout_marginRight="16dp"
             android:layout_marginEnd="16dp"
             android:gravity="center_vertical"
+            android:singleLine="true"
+            android:ellipsize="none"
             android:textColor="#f5a623"
             android:textSize="24sp"
             android:text="@string/mediaBox_textBox_simpleText" />