As you can see on this image, I have a grey area where there are some imageview. This area is a LinearLayout inside an Horizontal Scrollview. Moreover on each imageview, there is a OnTouchListener which start a drag and drop when there is an ACTION_DOWN.
As you have understand, there is a problem when I try to scroll. Indeed, the ACTION_DOWN is "selected" so I can't scroll .
So I have thought several solutions:
- To put an higher area and the user can scroll where there is nothing.
- Not use OnTouchListener but OnLongClickListener
But none of these solutions is good for me. Do you have an idea how I could solve my problem ?
My xml code:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:background="#5d6164"
android:id="@+id/horizontalScrollView" >
<LinearLayout
android:id="@+id/area2_timetable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
</LinearLayout>
</HorizontalScrollView>
My OnTouch method:
View.OnTouchListener myOnTouchListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if (action==MotionEvent.ACTION_DOWN)
{
SharedPreferences mSharedPrefs = getSharedPreferences("User", Context.MODE_PRIVATE);
if(mSharedPrefs.getInt("son_active", 0)==1) Son(VariablesManagement.nom_stockage_meal.get(v.getId()));
ClipData data = ClipData.newPlainText("", "");
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
v.startDrag(data, shadowBuilder, v, 0);
}
return false;
}
};
I don't think my java code is useful so I didn't put it(in order to have a clear question) but don't hesitate to ask if you think it could help.
Thank you very much !