2013. 5. 2. 19:28

ScrollView 안에 EditText 의 scroll 이 먹지 않는 문제 

After struggling with that problem for quite some time, I've found a solution that seems to work without being too ugly. First, make sure that whatever ViewGroup (directly) contains your EditText has DescendantFocusability set to "Before Descendants," Focusable set to "true" and FocusableInTouchMode set to "true." This will not be the ScrollView itself, but the layout inside where you have your various views. Next add an onTouchListener to your ScrollView that removes focus from the EditText whenever it is touched, like so:

ScrollView scroll = (ScrollView)findViewById(R.id.scrollView1);
scroll.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (myEditText.hasFocus()) {
            myEditText.clearFocus();
        }
        return false;
    }
});

Tell me if that doesn't fix it. What should happen is that the Layout gets focus instead of the EditText, so no scrolling should happen.


이외에 하나더있음. 정리중...

'Android > 개발팁' 카테고리의 다른 글

Android log 작성법  (0) 2013.05.22
패키지 네이밍 !  (0) 2013.05.07
EditText 테두리 없애기  (0) 2013.02.26
Android click 과 longclick 구분 방법  (0) 2013.01.08
3G, WIFI 연결 상태 확인하기.  (0) 2012.12.07
Posted by hoonihoon