我想在 EditText 对象中禁用滚动。我遵循了这一点,但它导致 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"
/>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句