2016-04-14 16 views
0

ImageView yüksekliğini ayarladığımda, görüntünün içinde bir otomatik yukarı doğru kaydırmaya neden olduğunda, NestedScrollView içindeki RelativeView içinde bir ImageView var. Wrap_content olmak için ImageView yüksekliğini ayarladığımda bu davranış gerçekleşmez. Sebebi ne olabilir? Bu destek kitaplığında bir çeşit hata mı?ImageView, NestedScrollView öğesinin otomatik olarak yukarı doğru kaydırılmasına neden oluyor

Notlar: 170 & RelativeLayout bu yükseliş otomatik kaydırma olmaz kaldırıldı olarak ben ImageView yüksekliğini muhafaza ederse

.

RelativeLayout &'u saklıyorsam, ImageView yüksekliğini wrap_content olarak ayarladım, bu yukarı doğru otomatik kaydırma gerçekleşmez.

<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> 

Güncelleme & Fix:

android Ekleme: descendantFocusability = "blocksDescendants" dikey LinearLayout olmaya sorunu giderilmiştir için:

<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

Herhangi bir öneri? –

cevap

0

ben çözümü ve nedeni bulundu Sorun, Yukarıdaki kodda, bir Dikey LinearLayout içinde RelativeLayout var ve eklediğimde

Dikey LinearLayout için

, sorun giderildi.

İlgili konular