Question

I have a ListView and here is its row layout

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="280dp">
<ScrollView
    android:scrollbars="none"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:id="@+id/exploreImage"
        android:src="@drawable/beard1"
        android:adjustViewBounds="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</ScrollView>
<TextView
    android:id="@+id/exploreText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>

I had to implement ScrollView in my layout, description is here.

So, my trouble is OnItemClickListener that I set to listView doesnt work. I could implement OnTouchListener, but in the case I need to know position and id of the clicked item.

UPD1: code of my listView. Here it is

 <ListView 
    android:id="@+id/exploreList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

UPD2: I dont need to scroll this ScrollView, only ListView. Also I want OnItemClickListener work.

Any ideas? Thanks.

Was it helpful?

Solution 2

Well, I have researched comments and aswers and tried to implement other solution. And here what I found.

The requirement was - to bind the image to the top and sides of View with cropping it in the bottom. But this View is implemented like item in the ListView, so I have to save all the focuses and listeners in the ListView.

Cause the ScrollView destroys the focuses and listeners, it cant be implemented.

Cropping the image programmaticaly takes a lot of time in the case of big pictures. It also cant be implemented.

The way I decided to do it is overriding the onMeasure method in the ImageView, like it's described in the topic.

I hope it will help to anyone.

OTHER TIPS

The problem is: Your ScrollView.

The basic answer we can give: Find another way to display the image inside the row in the way you want it. Basically just search on how to crop an image and crop it so that it fits.

Untested code to crop your image:

Bitmap croppedBitmap = Bitmap.createBitmap(bitmapOriginal, destWidth, destHeight, bitmapOptions);

Some alternative methods can be found in the Bitmap documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top