Arrêter le ScrollView de la mise au point sur EditText
Android ScrollView (lors d'un défilement ou la jeter en avais) aime réglez la mise au point d'un EditText quand c'est l'un de ses enfants. Cela se produit lorsque vous faites défiler puis relâchez-le. Est-il de toute façon à mettre fin à ce comportement? J'ai essayé à peu près tout ce que je pense et tout ce que j'ai lu sur StackOverflow. Rien n'a fonctionné pour moi. Ci-dessous est un exemple de mise en page Si vous souhaitez le tester. Je suis désespérée d'arrêter cette stupide comportement.
<?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>
Vous devez vous connecter pour publier un commentaire.
Cela fonctionne. Vous ne savez pas si c'est la meilleure solution ou pas.
ScrollView
et aussi des résultats dans un étrange changement dans la couleur de fond.Tout d'abord, vous pouvez supprimer le parent de la ScrollView.
Deuxièmement, mettre l'accent options pour l'enfant(un seul enfant par le ScrollView):
C'est comment votre xml devrait ressembler à:
Notez également que vous disposez de plusieurs id avec le même nom. Essayez de leur donner des noms uniques.
Si vous voulez seulement de masquer le doux-clavier, et de laisser le EditText encore c'est le focus, vous pouvez le faire en ajoutant la propriété suivante à votre activité en manifeste:
ah, il est très tard. Mais je veux encore ajouter à cette solution pour aider les débutants comme moi.
oui, il fonctionne, il suffit de définir un écouteur à clearfocus. et c'est mieux qu'ing requestFocusFromTouch un autre point de vue "x", ce qui conduit au même problème-- srolling à la vue "x".