Android ScrollView跳转到EditText

Android ScrollView跳转到EditText,android,android-edittext,scrollview,Android,Android Edittext,Scrollview,当我启动应用程序时,它会自动跳入第一个“编辑文本”框。 我内置了一个滚动条 当我移除滚动条时,它不会跳入“编辑文本”框 为什么它会跳入“编辑文本”框?我不喜欢它跳进那个盒子里/ 代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vert

当我启动应用程序时,它会自动跳入第一个“编辑文本”框。 我内置了一个滚动条

当我移除滚动条时,它不会跳入“编辑文本”框

为什么它会跳入“编辑文本”框?我不喜欢它跳进那个盒子里/

代码如下:

<?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="wrap_content">

<TextView 
    android:id="@+id/textView1" 
    android:layout_height="wrap_content" 
    android:text="Brutto- oder Nettobetrag eingeben:" 
    android:layout_width="fill_parent">
</TextView>

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content">

        <EditText 
            android:id="@+id/edt_betrag"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:inputType="numberDecimal"/>

        <RadioGroup 
            android:id="@+id/rg_art"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <RadioButton 
                android:id="@+id/rb_art_netto"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Netto" 
                android:checked="true" />

            <RadioButton 
                android:id="@+id/rb_art_brutto"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Brutto" />

            <TextView 
                android:id="@+id/textView2" 
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent" 
                android:text="Prozentsatz eingeben:">
            </TextView>

            <EditText 
                android:layout_height="wrap_content" 
                android:layout_width="match_parent" 
                android:id="@+id/eigener_betrag"
                android:inputType="numberDecimal">
            </EditText>     

        </RadioGroup>

        <Button 
            android:id="@+id/Button01main" 
            android:text="Berechnen" 
            android:layout_height="50dip" 
            android:layout_width="fill_parent" 
            android:layout_gravity="center" android:layout_marginBottom="20dip">
        </Button>

        <Button 
            android:layout_height="wrap_content" 
            android:id="@+id/zurueck" 
            android:text="Zurück" 
            android:layout_gravity="left" 
            android:layout_width="150dip">
        </Button>

    </LinearLayout>
</ScrollView>


我自己解决了这个问题:

        android:focusable="true" 
        android:focusableInTouchMode="true">
这就是问题所在;) 添加于


要解决此程序,通常应编写如下代码

    ScrollView scroll = (ScrollView)findViewById(R.id.my_scroll);
    scroll.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scroll.setFocusable(true);
    scroll.setFocusableInTouchMode(true);
    scroll.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });
    ScrollView scroll = (ScrollView)findViewById(R.id.my_scroll);
    scroll.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scroll.setFocusable(true);
    scroll.setFocusableInTouchMode(true);
    scroll.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });