久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

停止 ScrollView 將焦點設置在 EditText

Stop ScrollView from setting focus on EditText(停止 ScrollView 將焦點設置在 EditText)
本文介紹了停止 ScrollView 將焦點設置在 EditText的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

Android 的 ScrollView(當滾動或甩動時)喜歡在 EditText 是其中一個子項時設置它的焦點.當您滾動然后釋放時會發生這種情況.有沒有辦法阻止這種行為?我已經嘗試了幾乎所有我能想到的以及我在 StackOverflow 上讀到的所有內容.沒有什么對我有用.下面是一個示例布局,如果您想對其進行測試.我迫切地想要阻止這種愚蠢的行為.

Android's ScrollView (when scrolled or fling'd) likes to set the focus of an EditText when it's one of it's children. It happens when you scroll and then release. Is there anyway to stop this behavior? I've tried nearly everything I can think of and everything I've read on StackOverflow. Nothing has worked for me. Below is an example layout If you'd like to test it out. I'm desperate to stop this dumb behavior.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<ScrollView 
    android:id="@+id/scrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginRight="50dp"
    android:focusable="true"
    android:focusableInTouchMode="true"
    >

    <EditText 
        android:layout_width="fill_parent" 
        android:layout_height="100dp" 
        android:text="TestApp 1"
        />


    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="TestApp 1"
        />

    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="TestApp 1"
        />

    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="TestApp 1"
        />

    <EditText 
        android:layout_width="fill_parent" 
        android:layout_height="100dp" 
        android:text="Bleh...."
        />

    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="TestApp 1"
        />
    <EditText 
        android:layout_width="fill_parent" 
        android:layout_height="100dp" 
        android:text="TestApp 1"
        />


    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="TestApp 1"
        />

    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="MeeEEEEEEEEEEEEE"
        />

    <Button 
        android:id="@+id/btn"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="TestApp 1"
        />



</LinearLayout>
</ScrollView>

</LinearLayout>

推薦答案

這行得通.不確定這是否是最好的解決方案.

This works. Not sure if it's the best solution or not.

// SCROLL VIEW HACK
    // BOGUS
    ScrollView view = (ScrollView)findViewById(R.id.scrollView);
    view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });

這篇關于停止 ScrollView 將焦點設置在 EditText的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 国产精品久久久久aaaa九色 | 国产欧美一区二区三区久久手机版 | 九九九视频 | 国产精品区二区三区日本 | 成人区精品一区二区婷婷 | 国产高清一区二区 | 久久999 | 婷婷福利 | 免费一区在线 | 九九热精 | 91免费看片 | 久久人体视频 | 久久国产高清 | av一级在线观看 | 伊人狠狠操 | 欧美毛片免费观看 | 国产日韩一区二区 | 国产四区 | 日日夜夜视频 | 天天摸天天看 | 久久国产亚洲精品 | 狠狠狠干 | 欧美一区二区三区在线观看 | 精品久久一区 | 国产自产21区 | 国产精品国产三级国产aⅴ中文 | 亚洲成人精品国产 | 久久久久久美女 | 凹凸日日摸日日碰夜夜 | 久久久亚洲 | 自拍视频网 | 一级欧美一级日韩片 | 四虎影视一区二区 | 亚洲精品成人 | 人人人干 | 拍真实国产伦偷精品 | 中文字幕在线精品 | 亚洲自拍偷拍免费视频 | 欧美一级二级在线观看 | 欧美vide| 国产三级大片 |