2016-04-14 6 views
0

ImageViewがNestedScrollViewの内部にあるRelativeView内にあります。ImageViewの高さを設定すると、インフレーション直後に自動的に上方向にスクロールします。この動作は、ImageViewの高さをwrap_contentに設定した場合には発生しません。理由は何でしょうか?サポートライブラリに何らかのバグがありますか?ImageViewによってNestedScrollViewが自動的に上にスクロールします

注:

私は170とImageViewの高さを保持していた場合&は、この上向きの自動スクロールが発生しませんRelativeLayoutを削除しました。

RelativeLayoutを&に設定した場合、ImageViewの高さをwrap_contentに設定すると、上向きの自動スクロールは発生しません。

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.mydomain.test"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="10dp"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="10dp"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="170dp" 
       android:scaleType="fitXY" 
       android:src="@drawable/cover"/> 

    </RelativeLayout> 
</LinearLayout> 
</android.support.v4.widget.NestedScrollView> 

更新&フィックス:

は、Androidの追加:垂直のLinearLayoutにdescendantFocusabilityは= "blocksDescendants" に問題を修正:

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.mydomain.test"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="10dp" 
    android:descendantFocusability="blocksDescendants"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="10dp"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="170dp" 
       android:scaleType="fitXY" 
       android:src="@drawable/cover"/> 

    </RelativeLayout> 
</LinearLayout> 
</android.support.v4.widget.NestedScrollView> 
+0

提案がありますか? –

答えて

0

Iは、溶液との理由を発見しました上記のコードでは、LinearLayoutの内部にRelativeLayoutがあり、追加したときに

android:descendantFocusability="blocksDescendants" 

to LinearLayout、問題は修正されました。

関連する問題