I eine Image innen RelativeView haben, die innerhalb NestedScrollView ist, wenn ich die Image Höhe eingestellt, die bewirkt, dass es eine automatische Aufwärts-Scroll direkt nach der Inflation. Dieses Verhalten tritt nicht auf, wenn ich die ImageView-Höhe auf wrap_content einstelle. Was könnte der Grund sein? Ist das ein Fehler in der Support-Bibliothek?Image verursacht NestedScrollView automatisch nach oben zu bewegen
Hinweise:
Wenn ich die Image Höhe gehalten als 170 & entfernt die RelativeLayout diese nach oben Autoscroll nicht passiert.
Wenn ich die RelativeLayout & ImageView Höhe auf wrap_content eingestellt halten, geschieht dies nicht Auto-Scroll automatisch nach oben.
<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>
aktualisieren & Fix:
android Hinzufügen: descendantFocusability = "blocksDescendants", um die vertikale Linearlayout das Problem behoben zu sein:
<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>
Irgendwelche Vorschläge? –