在代码中启用或禁用编辑文本转动(如果按下“编辑”按钮)。
问题是:如果edittext包含大文本并且其状态被禁用,则我无法滚动水平以查看所有文本。 (如果他的状态已启用,我可以正常水平滚动)
答案 0 :(得分:0)
如果您将EditText
包裹在HorizontalScrollView
中,即使禁用了EditText,用户也可以水平滚动它:
<HorizontalScrollview
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</HorizontalScrollView>
答案 1 :(得分:0)
您可以在edittext中使用以下参数。
edittext.setFocusable(false);
edittext.setClickable(false);
edittext.setFocusableInTouchMode(false);
edittext.setEnabled(true);
edittext.setKeyListener(null);
edittext.setHorizontallyScrolling(true);
因此它将作为理想的行为。
答案 2 :(得分:0)
这是我在XML中的Edittext
int
并在JAVA中添加此内容,
<EditText
android:id="@+id/et_myEdtitText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
/>
现在我无法在Edittext中添加任何文字。因为,我已禁用KeyListener,但我可以水平滚动您的Edittext