0

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.

Community
  • 1
  • 1
kio_tk
  • 47
  • 7
  • 1
    Where do you have your listview? I don't see a listview! – WarrenFaith Feb 14 '14 at 15:45
  • @WarrenFaith I showed a code of my row layot, will code of my ListView code will help? Oo – kio_tk Feb 14 '14 at 15:47
  • Assuming you want to detect the item in the list that was clicked why no use onListItemClick ? If you dont want to detect the list item that was clicked then I didn't understand your question. – pedromss Feb 14 '14 at 15:48
  • 1
    Ok how do you expect the both scroll container (the ListView and the ScrollView in your row) to figure out, what you want to scroll? Imho your design is flawed! – WarrenFaith Feb 14 '14 at 15:49
  • @pedromss exactly, I want to detect wich item was clicked. I wrote, that OnItemClickListener doesnt work cause of ScrollView in my row layout. – kio_tk Feb 14 '14 at 15:51
  • @WarrenFaith I dont need to scroll my ScrollView, and I linked an answer why I have to use ScrollView. Do you read the question at all? – kio_tk Feb 14 '14 at 15:52
  • Take out the scrollview..? – t0mm13b Feb 14 '14 at 15:56
  • @t0mm13b I have to implement it here. The question how to let OnItemClickListener work, I dont need to scroll this ScrollView – kio_tk Feb 14 '14 at 15:59
  • @WarrenFaith's comment is +1, why a scrollview inside a listview? It does not make sense... you need to fully explain the rationale and reasoning behind it... – t0mm13b Feb 14 '14 at 16:00
  • @t0mm13b do u see the link in the question? There is my description why I need it. Should I copypaste it to my question? – kio_tk Feb 14 '14 at 16:04
  • Whoa! We're not a coding service for free... you clearly need to do a bit more education and research into this *yourself*, we're not a crutch for your one-shot programming exercises. [What have you tried](http://whathaveyoutried.com)? – t0mm13b Feb 14 '14 at 16:06
  • Guuuys, you even cant read my question properly. Anyway thanks for attention – kio_tk Feb 14 '14 at 16:12

2 Answers2

0

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.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
0

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.

Community
  • 1
  • 1
kio_tk
  • 47
  • 7