@Composable
fun CustomStyledTextField(
) {
var text by remember { mutableStateOf("搜索") }
// Define the text style with desired font size
val textStyle = TextStyle(
fontSize = 8.sp, // Set the font size here
fontWeight = FontWeight.Normal // You can adjust font weight as needed
)
Box(
modifier = Modifier
.size(374.dp.px(), 50.dp.px())
.background(Color(0xffffff00), shape = RoundedCornerShape(15))
// .border(0.dp, Color.Gray, shape = RoundedCornerShape(8.dp))
.padding(1.dp).padding(start = 2.dp)
) {
BasicTextField(
textStyle = textStyle,
value = text,
onValueChange = {
text = it
},
// modifier = Modifier.fillMaxWidth(),
singleLine = true,
decorationBox = { innerTextField ->
Row(
verticalAlignment = Alignment.CenterVertically
) {
// Place the text field
Box(modifier = Modifier.weight(1f)) {
innerTextField()
}
// Image(
// painter = painterResource(id = R.drawable.search_icon),
// contentDescription = "Vector Image Example",
// modifier = Modifier.size(70.dp.px(),42.dp.px()) // Adjust size if needed
// )
// Add an icon at the end
Icon(
imageVector = Icons.Default.Search,
contentDescription = "Search Icon",
modifier = Modifier.size(24.dp)
)
}
}
)
}
}
@Composable
fun CustomStyledTextField(
) {
var text by remember { mutableStateOf("搜索") }
// Define the text style with desired font size
val textStyle = TextStyle(
fontSize = 8.sp, // Set the font size here
fontWeight = FontWeight.Normal // You can adjust font weight as needed
)
Box(
modifier = Modifier
.size(374.dp.px(), 50.dp.px())
.background(Color(0x66ffffff), shape = RoundedCornerShape(15))
// .border(1.dp, Color.Gray, shape = RoundedCornerShape(1.dp))
.padding(1.dp)
.padding(start = 2.dp)
) {
BasicTextField(
textStyle = textStyle,
value = text,
onValueChange = {
text = it
},
singleLine = true,
decorationBox = { innerTextField ->
Row(
verticalAlignment = Alignment.CenterVertically
) {
// Place the text field
Box(modifier = Modifier.weight(1f)) {
innerTextField()
}
// Add an icon at the end
Box(modifier = Modifier.background(Color.Blue, shape = RoundedCornerShape(15)).clickable { }) {
Icon(
imageVector = Icons.Default.Search,
tint = Color.White,
contentDescription = "Search Icon",
modifier = Modifier.size(24.dp)
)
}
}
}
)
}
}