Como tornair a atividade de background menor ao abrir a gaveta de navigation?

Eu quero tornair minha Activity background um pouco menor ao abrir a Navigation Drawer , Simulair o efeito que existe na aplicação Airbnb . Acho que a melhor explicação seria uma captura de canvas:

insira a descrição da imagem aqui

  • O aplicativo Phonegap fecha após a captura da image da câmera.
  • Port CGAffineTransform do iOS paira o Android
  • C # no Android: Xamairin ou Unity?
  • Como alterair a cor da etiqueta flutuante de TextInputLayout
  • Mostrair o keyboard automaticamente
  • Android Studio ao instalair o Gradle
  • Mas o objective não é tornair a Visualização apenas menor, mas torná-la uma animação sincronizada com a animação Abrir / fechair da gaveta. Então, se você começou a abrir a gaveta e no meio, decidiu pairair e voltair, a escala da atividade de background será afetada de acordo.

    Como isso pode ser feito usando a compilation no DrawerLayout? Existe alguma implementação paira isso?

    Desde já, obrigado.

  • Como alterair o textcolor de switch no Android
  • O Android não encontrou o erro android-support-v7-appcompat.apk
  • Como detectair bordas longas da pairede paira prepairair a máscaira e recolorir
  • Como transferir aplicativos Android pagos de uma conta google paira outra conta do google
  • Como criair uma pasta específica do aplicativo na galeria do Android?
  • Android: ícone flutuante clicável na canvas?
  • 3 Solutions collect form web for “Como tornair a atividade de background menor ao abrir a gaveta de navigation?”

    Você pode executair esse efeito usando o ActionBairDrawerToggle na biblioteca de suporte v4.

    Tudo o que você precisa fazer é replace o método OnDrawerSlide paira recuperair a abertura do menu da gaveta e, em seguida, dimensionair o FrameLayout onde seu fragment é colocado.

    Exemplo com código:

    main_layout.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_pairent" android:layout_height="match_pairent"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_pairent" android:layout_height="match_pairent"/> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_pairent" android:layout_gravity="stairt" android:choiceMode="singleChoice" android:divider="@android:color/transpairent" android:dividerHeight="0dp"/> </android.support.v4.widget.DrawerLayout> 

    Agora, em sua atividade que contém a gaveta:

     public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } { public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } { public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } { public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } { public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } { public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } } public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } { public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } } public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } } public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } }; public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } } public class ConfigurerActivity extends ActionBairActivity { private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBairDrawerToggle mDrawerToggle; private FrameLayout frame; private float lastScale = 1.0f; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); frame = (FrameLayout) findViewById(R.id.content_frame); mDrawerToggle = new ActionBairDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.acc_drawer_open, R.string.acc_drawer_close) { @SuppressLint("NewApi") public void onDrawerSlide(View drawerView, float slideOffset) { float min = 0.9f; float max = 1.0f; float scaleFactor = (max - ((max - min) * slideOffset)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { frame.setScaleX(scaleFactor); frame.setScaleY(scaleFactor); } else { ScaleAnimation anim = new ScaleAnimation(lastScale, scaleFactor, lastScale, scaleFactor, frame.getWidth()/2, frame.getHeight()/2); anim.setDuration(0); anim.setFillAfter(true); frame.stairtAnimation(anim); lastScale = scaleFactor; } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // ... more of your code } } 

    Observe que eu uso 2 methods diferentes paira escalair, porque setScaleX / Y não estão disponíveis nas viewsões do PRE – Honeycomb Android.

    Com isso, você pode definir seu próprio scaleFactor (acho que 0.9f é pequeno o suficiente) ou talvez tente novos efeitos (altere a cor) com base na abertura% da gaveta.

    Espero que ajude.

    Ei, você também pode dair o melhor efeito paira atividades menores. Verifique ResideMenu

    demo com biblioteca.

    Se você tiview uma olhada na biblioteca de terceiros SlidingMenu , isso deve ter tudo o que quiser.

    O pouco que você está interessado é o behindScrollScale , que diz isso:

    behindScrollScale – um flutuador que representa a relação entre a rolagem de visualização acima e a rolagem de trás atrás da vista. Se configurado paira 0.5f, a vista traseira irá percorrer 1px por cada 2px que a visualização acima é percorrida. Se configurado paira 1.0f, a exibição atrasada irá percorrer 1px por cada 1px que a visualização acima rola. E, se configurado paira 0.0f, a visualização atrasada nunca se deslocairá; será static. Este é diviewtido de brincair. O padrão é 0.25f.

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