【发布时间】:2021-06-16 10:14:14
【问题描述】:
【问题讨论】:
-
尝试减少
fontSize,你也可以修改高度和样式
标签: android textfield android-jetpack-compose
【问题讨论】:
fontSize,你也可以修改高度和样式
标签: android textfield android-jetpack-compose
我们可以通过CoreTextField.cursorBrush自定义文本字段光标,带有Brush.verticalGradient和colorStops参数。
BasicTextField(
cursorBrush = Brush.verticalGradient(
0.00f to Color.Transparent,
0.35f to Color.Transparent,
0.35f to Color.Green,
0.90f to Color.Green,
0.90f to Color.Transparent,
1.00f to Color.Transparent
)
)
【讨论】:
res/drawable/custom_cursor.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size
android:width="2dp"// cursor width
android:height="28dp" />// cursor height should be noted that the height can not be set edittext adaptation, otherwise, the cursor height or size of the input character
<solid android:color="@color/azure" />// color of the cursor
<padding // This parameter allows the cursor is highly inconsistent with the text size, text size I need is here 14dp
android:bottom="7dp"
android:top="7dp" />
</shape>
在您的编辑文本中:
android:textCursorDrawable="@drawable/custom_cursor"
【讨论】: