在我的应用程序中,我有一行用于增加窗口小部件的宽度(通过向右/向左拖动线),并且我ScrollView在相同的活动中启用了.我需要在用户触摸该行时禁用滚动视图操作,当用户释放时,应该启用它.本ScrollView应在可视状态,但滚动视图的作用应该被禁用.请帮我解决这个问题.我试过这些,但没有一个是有效的.
scroll.setEnabled(false);
scroll.setFocusable(false);
scroll.setHorizontalScrollBarEnabled(false);
scroll.setVerticalScrollBarEnabled(false);
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我搜索了关于这个主题的所有帖子,但我仍然找不到任何解决方案.我有一个大的布局,它可以使用ScrollView滚动,它还有可滚动的EditText.如果我尝试滚动edittext,则布局开始滚动.我怎么解决呢?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="@+id/lroot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/img6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:onClick="runInfo"
android:src="@drawable/info_btn" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/splash" />
<!-- Scrollable EditText -->
<EditText
android:id="@+id/EditText01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:autoLink="all"
android:background="@drawable/isim_soyisim"
android:clickable="true"
android:cursorVisible="true"
android:gravity="left|top"
android:scrollbars="vertical"
android:inputType="textMultiLine"
android:longClickable="false"
android:maxLines="5"
android:singleLine="false"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个讨厌的问题.我有EditText(8行)里面ScrollView.当我试图滚动文本时,EditText它的行为并不稳定.有时它会滚动,有时它不会聚焦.
这是我的布局文件,让我的问题更清晰:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:id="@+id/wo_task_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_comments_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/comments" />
<Button
android:id="@+id/wo_task_select_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_comment_from_template" />
<EditText
android:id="@+id/wo_task_comments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:hint="@string/enter_your_comment_here"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:scrollbars="vertical"
android:singleLine="false" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我知道我有这个问题,因为在另一个内部有一个可滚动的控件,但我不知道该怎么做.所以,如果可以,请帮助我.
提前致谢.
public void initComments(final View view) {
EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);
comment.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent motionEvent) {
if (view.getId() …Run Code Online (Sandbox Code Playgroud) 我已经搜索了解决方案,但似乎这些都没有用.我的情况不适用于更换xml吗?如何解决问题?滚动视图工作但edittext无法正常工作.谢谢
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/share_bg" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:overScrollMode="never" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/photo_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/share_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/photo_area"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="@string/share_title"
android:textColor="@android:color/white" />
<EditText
android:id="@+id/share_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/share_title"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/custom_textarea"
android:gravity="top|left"
android:lines="5"
android:scrollbars="vertical"
android:text="@string/default_msg" >
<requestFocus />
</EditText>
<ImageView
android:id="@+id/share_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/share_content"
android:layout_centerHorizontal="true"
android:src="@drawable/photo_taken_btn_submit" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
id:share_content是editText,谢谢