简体   繁体   中英

ListView scrolling strange behaviour

I have a listView with some layout, I've simplified it for this question to the maximum, but it still doesn't work as epected. What happens it that:

1) first row of the ListView works properly: it is "grabbable", ie I can touch it and moving finger up or down, scroll it.

2) all other rows in the listView are grabbable only by "ikonka" and "tojkat" ImageViews

Here's the layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:gravity="bottom" >

    <ImageView
        android:focusable="false"
        android:id="@+id/ikonka"
        android:layout_width="@dimen/listview_album_art"
        android:layout_height="@dimen/listview_album_art"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:paddingBottom="@dimen/audio_player_icon_padding"
        android:paddingTop="@dimen/audio_player_icon_padding"
        android:scaleType="centerCrop" />

    <ImageView
        android:focusable="false"
        android:id="@+id/akcja"
        android:layout_width="@dimen/listview_album_art"
        android:layout_height="@dimen/listview_album_art"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="@dimen/audio_player_icon_padding"
        android:layout_marginTop="@dimen/audio_player_icon_padding"
        android:scaleType="centerCrop" />

    <ImageView
        android:focusable="false"
        android:id="@+id/trojkat"
        android:layout_width="50dip"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@null"
        android:scaleType="center"
        android:src="@drawable/ic_action_overflow" />

</RelativeLayout>

The adapter, simplified for the purpose of this question:

 public class AdapterTrackowDlaZapytan extends CursorAdapter {
LayoutInflater inflater = null;

public AdapterTrackowDlaZapytan(FragmentActivity c, Cursor cu, int flags) {
    super(c, cu, flags);

    inflater = (LayoutInflater) c
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public void bindView(View view, Context context, Cursor cursor) {
    // nothing really interesting here, besides ViewHolder, but even without it it works as described
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup vg) {
    ViewHolder holder;

    View v = inflater.inflate(R.layout.test_directory_row, vg, false);
    return v;
}

  }

I don't think it matters, but the ListView is part of a fragment that is created by FragmentStatePagerAdapter that is a member of a fragment that belongs to an Activity...

For me it looks like Android bug (the first row works!), but I might be wrong. Any thoughts?

EDIT: interestingly, filling the whole layout with new ImageView didn't change anything - only "old" ImageViews can be grabbed to scroll.

EDIT: even more interesting: making trojkat view width match_parent, doesn't change anything! Still only small areas on the left and right of the view can be used to scroll.

EDIT: oh, my! I've found it! What happens is that a fragment that is laying BELOW current fragment receives all scroll events! Now how would I override that stupid behaviour?!

EDIT AND SOLUTION: This is a bug that happens when using PageTransformer! Look for solution here: ListView inside ViewPager won't scroll when applying a PageTransformer

As I suspected, the bug is Android bug and it happens due to PageTransformer, see here:

ListView inside ViewPager won't scroll when applying a PageTransformer

It would be good to leave this question for anyone in the future looking for the answer, as this bug might manifest itself in very strange ways, and it is not so easy to guess it is caused by PageTransformer!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM