onImageTouchListener = new View.OnTouchListener(){ @Override public boolean onTouch(View view, MotionEvent motionEvent) { X=(int)motionEvent.getRawX(); Y=(int)motionEvent.getRawY(); switch(motionEvent.getAction()){ case MotionEvent.ACTION_DOWN: if(settingMode) { scrollView.requestDisallowInterceptTouchEvent(true); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams(); deltaX = X - params.leftMargin; deltaY = Y - params.topMargin; } break; case MotionEvent.ACTION_MOVE: if(settingMode) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams(); if (X - deltaX > 0 && X - deltaX + params.width < scrollView.getWidth()) params.leftMargin = X - deltaX; if (Y - deltaY > 0 ) params.topMargin = Y - deltaY; System.out.println("move " + params.leftMargin); System.out.println("move " + params.topMargin); view.setLayoutParams(params); } break; } return true; } };E il comportamento è adeguato.
Ora (ho fatto un intermezzo per realizzare il collegamento di questa App al database Firebase) devo gestire il comportamento al tocco in caso di settingMode=false.
Devo ricostruire il tts.
Ma prima voglio provare l'introduzione delle textViews nascoste contenenti il TIPO e la CATEGORIA del folderLayout.
In precedenza avevo castato il layout a viewgroup, e vediamo se si può fare lo stesso... Ecco, sì, ci sono riuscito:
case MotionEvent.ACTION_DOWN: if(settingMode) { scrollView.requestDisallowInterceptTouchEvent(true); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams(); deltaX = X - params.leftMargin; deltaY = Y - params.topMargin; } else{ String tipo=(String)((TextView)((ViewGroup)view).getChildAt(2)).getText(); String categoria=(String)((TextView)((ViewGroup)view).getChildAt(3)).getText(); } break;Provando con System.out.println ottengo la stampa a video di tipo e categoria.
Ora devo sistemare il tts.
Ho fatto tanta strada senza documentarla.
tts risistemato, sistemate le coordinate delle immagini, sistemato il cambio di schermata...
Nessun commento:
Posta un commento