gpt4 book ai didi

android - 在 edittext 提示中需要水平滚动

转载 作者:行者123 更新时间:2023-11-29 01:17:39 25 4
gpt4 key购买 nike

在我的应用程序中,我有固定大小的编辑文本,但提示大小大于编辑文本,因此提示未完全显示。我想通过水平滚动来完全显示提示,但我不知道如何执行此操作。

如果减小提示字体的大小会有帮助,但我不想减小字体大小。

以下是我使用的示例代码。

<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:singleLine="true"
android:id="@+id/test_etx"
android:hint="@string/hint"
android:layout_below="@+id/bt3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp"
android:layout_alignRight="@+id/etx"
android:layout_alignEnd="@+id/etx"
android:maxLength="10"
/>

最佳答案

使您的 EditText 宽度与父级匹配。把它放在水平 ScrollView 中。我试过了,它有效。如果您想要固定宽度,请为水平 ScrollView 提供固定宽度。像这样:

<HorizontalScrollView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bt3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp"
android:layout_alignRight="@+id/etx"
android:layout_alignEnd="@+id/etx">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:singleLine="true"
android:id="@+id/test_etx"
android:hint="@string/hint"
android:maxLength="10"/>
</HorizontalScrollView>

关于android - 在 edittext 提示中需要水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38605237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com