java - 在 EditText 中禁用滚动效果并且仍然有可见的光标

标签 java android jquery xml android-studio

我想在 EditText 对象中禁用滚动。我关注了this但它导致 EditText 内的光标消失,这不是预期的。我想禁用滚动效果但仍希望光标位于 EditText 内。这是 EditText 对象的 XML。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_gravity="top|center"
    android:background="@color/grayBackground"
    android:orientation="horizontal"
    android:padding="8dp"
    android:layout_margin="10dp">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_view_carousel_grey_24dp"
        android:layout_gravity="center_vertical"
        android:paddingStart="2dp"
        android:paddingEnd="8dp"/>

    <EditText
        android:id="@+id/search_product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:background="@android:color/transparent"
        android:hint="@string/searchProducts"/>

</LinearLayout>

最佳答案

如果你想禁用编辑文本框的滚动设置 layout_height 的静态高度

<EditText

<!--set static height instead of giving wrap content-->
        android:layout_height="wrap_content"
        />

关于java - 在 EditText 中禁用滚动效果并且仍然有可见的光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43388151/

相关文章:

android - 如何在我的项目中使用 Android Wheel?

javascript - jQuery(this) 目标找不到元素

javascript - 定位父 div 的最佳方式 - javascript

java - 为什么当可观察对象作为新线程运行时观察者没有收到通知?

java - 如何?在 Java 中绘制自定义复合对象

java - 是否为 S.O.P 创建了一个新的字符串对象?

android - 使用后退键关闭 Android 弹出窗口

java - "Share"带有另一部智能手机的 sqlite 表

jquery - 使用 && 或 || CDN 后备 - 有区别吗?

java - 将整数颜色值转换为 RGB