Gezinme çekmecesinde oldukları sıraya göre parçalar arasında yukarı ve aşağı doğru kayabilmeyi istiyorum. Bunun bir örneği de Facebook Messenger ile yaptıkları şeydi, diyelim ki ilk sekme ile dördüncü sekme arasında geçiş yapmak istiyorum, 4. sekmeye getirmeden önce 1., 2. ve 3. sekmelerden hızlıca geçecek. Uygulamamda bu tür bir animasyonu nasıl kopyalarım.Android - Gezinme Çekmecesi parçaları arasında kaydırma yapmak için animasyonlar
MainActivity.java
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
NavigationView navigationView = null;
Toolbar toolbar = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Disables Orientation throughout the entire application
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//Set the fragment initially
WelcomeFragment fragment = new WelcomeFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
navigationView = (NavigationView) findViewById(R.id.nav_view);
//How to change elements in the header programatically
View headerView = navigationView.getHeaderView(0);
TextView emailText = (TextView) headerView.findViewById(R.id.description);
emailText.setText("Scouting Application");
navigationView.setNavigationItemSelectedListener(this);
} //End of onCreate
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
} //End of if statement
} //End of onBackPressed
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_welcome) {
//Set the fragment initially
WelcomeFragment fragment = new WelcomeFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
// Handle the camera action
}
else if (id == R.id.nav_facebook) {
FacebookFragment fragment = new FacebookFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
}
else if (id == R.id.nav_scout) {
//Set the fragment initially
ScoutFragment fragment = new ScoutFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
}
else if (id == R.id.nav_match) {
//Set the fragment initially
MatchFragment fragment = new MatchFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
} //End of onNavigationItemSelected
} //End of class