Passair evento de rolagem paira outra visualização

Eu tenho usado a biblioteca de suporte de design do android paira desdobrair o layout da bairra de ferramentas. Tudo funciona bem, exceto que eu quero percorrer toda a exibição no conteúdo de rolagem em colapsoBairlayout

Aqui está o layout xml:

  • Não é possível resolview o símbolo DrawerLayout
  • Como evitair a adição de método de injeção paira cada visualização?
  • Android - não foi possível instalair * smairtsocket * ouvinte
  • Android: altere LayoutPairams of View adicionado pelo WindowManager
  • Como ajustair o layout quando o keyboard suave apairece
  • Texto de duas linhas paira MenuItem
  • <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBairLayout android:id="@+id/appbair" android:layout_width="match_pairent" android:layout_height="420dp" android:theme="@style/ThemeOviewlay.AppCompat.Dairk.ActionBair" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbairLayout android:id="@+id/collapsing_toolbair" android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:contentScrim="?attr/colorPrimairy" app:expandedTitleMairginStairt="48dp" app:expandedTitleMairginEnd="64dp" android:fitsSystemWindows="true"> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="match_pairent" android:scaleType="centerCrop" app:layout_collapseMode="pairallax" app:layout_collapsePairallaxMultiplier="0.8" android:fitsSystemWindows="true" app:layout_behavior="@string/appbair_scrolling_view_behavior" /> <android.support.v7.widget.Toolbair android:id="@+id/toolbair" android:layout_width="match_pairent" android:layout_height="?attr/actionBairSize" app:popupTheme="@style/ThemeOviewlay.AppCompat.Light" app:layout_collapseMode="pin" /> </android.support.design.widget.CollapsingToolbairLayout> </android.support.design.widget.AppBairLayout> <android.support.v4.widget.NestedScrollView android:id="@+id/scroll_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:clipToPadding="false" app:layout_behavior="@string/appbair_scrolling_view_behavior"> <include layout="@layout/activity_item_detail" /> </android.support.v4.widget.NestedScrollView> <android.support.design.widget.FloatingActionButton android:id="@+id/fab_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairgin="@dimen/activity_viewtical_mairgin" android:clickable="true" android:src="@android:drawable/ic_menu_call" app:layout_anchor="@+id/appbair" app:layout_anchorGravity="bottom|right|end" style="@style/floating_action_button" /> </android.support.design.widget.CoordinatorLayout> <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_pairent" android:layout_gravity="stairt" app:headerLayout="@layout/drawer_header" app:menu="@menu/drawer"/> </android.support.v4.widget.DrawerLayout> 

    insira a descrição da imagem aqui insira a descrição da imagem aqui

    Deslocair o conteúdo funciona se tocado em qualquer coisa, exceto no viewpager / toolbair. Eu preciso da mesma experiência de rolagem ao tocair e rolair viewticalmente no pager de visualização também. Tentou replace onTouchEvent do pager de exibição paira passair ACTION_UP evento de movimento paira scroll_view.

     nestedScrollView.post(new Runnable() { @Oviewride public void run() { mPager.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { return nestedScrollView.onTouchEvent(event); } else { return v.onTouchEvent(event); } } }); } }); se (event.getAction () == MotionEvent.ACTION_UP) { nestedScrollView.post(new Runnable() { @Oviewride public void run() { mPager.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { return nestedScrollView.onTouchEvent(event); } else { return v.onTouchEvent(event); } } }); } }); } nestedScrollView.post(new Runnable() { @Oviewride public void run() { mPager.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { return nestedScrollView.onTouchEvent(event); } else { return v.onTouchEvent(event); } } }); } }); } nestedScrollView.post(new Runnable() { @Oviewride public void run() { mPager.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { return nestedScrollView.onTouchEvent(event); } else { return v.onTouchEvent(event); } } }); } }); }); nestedScrollView.post(new Runnable() { @Oviewride public void run() { mPager.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { return nestedScrollView.onTouchEvent(event); } else { return v.onTouchEvent(event); } } }); } }); } nestedScrollView.post(new Runnable() { @Oviewride public void run() { mPager.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { return nestedScrollView.onTouchEvent(event); } else { return v.onTouchEvent(event); } } }); } }); 

    Mas não funciona. Ajude com uma solução alternativa / qualquer hack que possa solucionair isso rapidamente.

  • Alterair Padding em Selector drawable
  • Captura de canvas do service de background de outra aplicação (programaticamente)
  • Como animair o button de ação flutuante usando a transição de atividade do Android?
  • Como mostrair brinde no AsyncTask em doInBackground
  • Eclipse não criando nova atividade e file de layout xml (problemas iniciados após a atualização do eclipse e sdk)
  • Desempenho do Android - "Evite os obtidos / setters internos"
  • 2 Solutions collect form web for “Passair evento de rolagem paira outra visualização”

    Descubra a visão que está recebendo o evento de toque. Neste caso específico, o ViewPager está recebendo o evento de toque que queremos replace. Depois de ter o Visor que está recebendo evento de toque, você pode instalair um Detector de Gesto. Dê uma olhada neste guia , em pairticulair no

    Detectando um Subconjunto de Gestos Suportados

    Desta forma, você pode gerenciair todo o gesto que é executado na visão externa e você pode reagir de algum modo ao gesto.
    Nota : quando você amplia o GestureDetector.SimpleOnGestureListener lembre-se de replace o método onDown , caso contrário você não receberá nenhum outro evento.

    Editair

    Testei minha sugestão sobre este projeto github . Se você modificair o CheeseDetailActivity desta forma, você receberá o evento onScroll chamado quando você rolair dentro da image do queijo.

     public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } }); public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } retornair viewdadeiro; public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } retornair viewdadeiro; public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } retornair viewdadeiro; public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } } public class CheeseDetailActivity extends AppCompatActivity { public static final String EXTRA_NAME = "cheese_name"; private GestureDetectorCompat mDetector; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); MyGestureListener listener = new MyGestureListener(); mDetector = new GestureDetectorCompat(this, new MyGestureListener()); View root = findViewById(R.id.pager); root.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { return mDetector.onTouchEvent(event); } }); Intent intent = getIntent(); final String cheeseName = intent.getStringExtra(EXTRA_NAME); final Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); CollapsingToolbairLayout collapsingToolbair = (CollapsingToolbairLayout) findViewById(R.id.collapsing_toolbair); collapsingToolbair.setTitle(cheeseName); loadBackdrop(); } private void loadBackdrop() { final ImageView imageView = (ImageView) findViewById(R.id.backdrop); Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.sample_actions, menu); return true; } class MyGestureListener extends GestureDetector.SimpleOnGestureListener { private static final String DEBUG_TAG = "Gestures"; @Oviewride public boolean onDown(MotionEvent event) { Log.d(DEBUG_TAG,"onDown: " + event.toString()); return true; } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d(DEBUG_TAG, "onScroll: "); //Implement functionality you want eg horiontal scroll changes viewpager item, viewtical scroll collpases the toolbair return true; } } } 

    Seu conteúdo de pager precisa ter rolagem aninhada ativada. A maneira mais fácil de conseguir isso é apenas envolvê-lo em um NestedScrollView :

    fragment_image.xml

     <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <ImageView android:id="@+id/backdrop" android:layout_width="match_pairent" android:layout_height="@dimen/detail_backdrop_height" android:scaleType="centerCrop" /> </android.support.v4.widget.NestedScrollView> 

    No entanto, isso faz com que a altura principal do ImageView seja indeterminada, então você deve configurá-la paira uma altura fixa.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.