我正在尝试设计一个像谷歌搜索栏一样高度降低的搜索栏。但输入文本和占位符文本也被裁剪。
TextField(
value = searchText.value,
singleLine = true,
onValueChange = {
searchText.value = it
},
placeholder = { //placeholder text is also getting cropped
Text(
text = "Search",
fontSize = 20.sp,
)
},
textStyle = TextStyle(fontSize = 20.sp), // input text is getting cropped
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 10.dp)
.height(45.dp), // Here I have decreased the height
shape = RoundedCornerShape(22.dp),
)
Run Code Online (Sandbox Code Playgroud)
我的输入文本和占位符文本被裁剪 50%。怎么解决呢?
我有一个最大宽度的行,我想在开头放置一个图标,然后在末尾放置一个文本,然后再放置另一个图标。我有特定大小的图标,我希望文本填充剩余空间。
Row(
Modifier
.fillMaxWidth()
.height(30.dp)
){
Icon(Modifier.size(20.dp))
Text() // Fill this with remaining space available
Icon(Modifier.size(20.dp))
}
Run Code Online (Sandbox Code Playgroud)
如果我fillMaxWidth在文本中这样做,那么图标就会从视图中消失。
怎么做?
android android-jetpack-compose android-jetpack-compose-layout