Skip to content

Commit 9d6c0e5

Browse files
authored
Fix UI for Android TTS Engine. (#1735)
Set max number of lines of the input text field so that the buttons are still visible when the input text is long.
1 parent 2df43b3 commit 9d6c0e5

File tree

1 file changed

+5
-0
lines changed
  • android/SherpaOnnxTtsEngine/app/src/main/java/com/k2fsa/sherpa/onnx/tts/engine

1 file changed

+5
-0
lines changed

android/SherpaOnnxTtsEngine/app/src/main/java/com/k2fsa/sherpa/onnx/tts/engine/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import androidx.compose.foundation.layout.fillMaxSize
2222
import androidx.compose.foundation.layout.fillMaxWidth
2323
import androidx.compose.foundation.layout.padding
2424
import androidx.compose.foundation.layout.wrapContentHeight
25+
import androidx.compose.foundation.rememberScrollState
2526
import androidx.compose.foundation.text.KeyboardOptions
27+
import androidx.compose.foundation.verticalScroll
2628
import androidx.compose.material3.Button
2729
import androidx.compose.material3.ExperimentalMaterial3Api
2830
import androidx.compose.material3.MaterialTheme
@@ -109,6 +111,7 @@ class MainActivity : ComponentActivity() {
109111
var rtfText by remember {
110112
mutableStateOf("")
111113
}
114+
val scrollState = rememberScrollState(0)
112115

113116
val numSpeakers = TtsEngine.tts!!.numSpeakers()
114117
if (numSpeakers > 1) {
@@ -142,9 +145,11 @@ class MainActivity : ComponentActivity() {
142145
value = testText,
143146
onValueChange = { testText = it },
144147
label = { Text("Please input your text here") },
148+
maxLines = 10,
145149
modifier = Modifier
146150
.fillMaxWidth()
147151
.padding(bottom = 16.dp)
152+
.verticalScroll(scrollState)
148153
.wrapContentHeight(),
149154
singleLine = false,
150155
)

0 commit comments

Comments
 (0)