Jak zapobiec przewijaniu widoku przewijania do widoku sieci Web po załadowaniu danych?
Więc mam fascynujący problem. Pomimo faktu, że nie jestem ręcznie lub programowo przewijania mój widok, mój WebView jest automatycznie przewijany do po załadowaniu danych wewnątrz niego.
Mam fragment w viewpagerze. Kiedy po raz pierwszy załadować pager, to działa zgodnie z oczekiwaniami i wszystko jest pokazane. Ale gdy "odwrócę stronę" ładuje się Dane i WebView wyskakuje na górę strony, ukrywając widoki nad nią, co jest niepożądane.
Czy ktoś wie jak zapobiec temu?
Mój layout wygląda tak:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/article_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:text="Some Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/article_title"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/LL_Seperator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@color/text"
android:orientation="horizontal" >
</LinearLayout>
<WebView
android:id="@+id/article_content"
android:layout_width="match_parent"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/article_link"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:text="View Full Article"
android:textColor="@color/article_title"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
Nie skupiam się też na niczym. Domyślnie wydaje się, że automatycznie przewija się do widoku sieci Web po załadowaniu. Jak temu zapobiec? 7 answers
Możesz po prostu dodać to do LinearLayout: android: focusableInTouchMode = "true". Dla mnie działa.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical" >
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-02 09:23:10
Miałem ten sam problem, Po godzinach próbowania kilku pomysłów, co w końcu zadziałało dla mnie po prostu dodanie atrybutu descendantFocusability
do ScrollView ' s zawierającego LinearLayout, o wartości blockDescendants
. W Twoim przypadku:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants" >
Od tamtej pory nie miałem problemu:)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-12-17 15:49:27
Powinieneś utworzyć nową klasę extend ScrollView, a następnie przesłać żądanie childfocus:
public class MyScrollView extends ScrollView {
@Override
public void requestChildFocus(View child, View focused) {
if (focused instanceof WebView )
return;
super.requestChildFocus(child, focused);
}
}
Następnie w układzie xml, używając:
<MyScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background" >
To mi pasuje. Widok przewijania nie będzie już automatycznie przewijać widoku sieci Web.Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-07-02 06:02:21
Dodanie tych linii w głównym układzie rozwiązuje problem
android:descendantFocusability="blocksDescendants"
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-06-04 20:36:40
Tak:
<com.ya.test.view.MyScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true" >
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-21 06:34:37
Prawdopodobnie są ludzie, którzy mają ten sam problem, co ja, więc pomogę.
Próbowałem umieścić android: descendantFocusability= "beforeDescendants" w moim głównym widoku przewijania w następujący sposób:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants">
/*my linearlayout or whatever to hold the views */
I nie działało, więc musiałem zrobić RelativeLayout rodzica widoku przewijania i umieścić android: descendantFocusability= "beforeDescendants" w rodzicu.
Więc rozwiązałem to robiąc co następuje:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
/*my linearlayout or whatever to hold the views */
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-23 14:21:06
Musiałem użyć w pełni kwalifikowanej nazwy dla MyScrollView, w przeciwnym razie dostałem wyjątek nadmuchiwania.
<com.mypackagename.MyScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background" >
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-30 18:57:13