Navigasyon Çekmece: her tablet üzerinde açık olarak ayarlayın
Destek kitaplığı Navigasyon Çekmece deseni kullanıyorum: http://developer.android.com/training/implementing-navigation/nav-drawer.html
Her zaman tablet (yan menü) açıldı gibi ayarlamaya çalışıyordum
Bir şey geçerli uygulama ile mümkündür, ya da aynı kodu yeniden yerine yeni bir düzen ve bir liste Görünümü ile yeni bir yapı oluşturmak zorunda mıyız?
CEVAP
Daha büyük cihazlar fikrine dayalı farklı düzeni dosyaları, oluşturmuş olabilir takip projesi.
https://github.com/jiahaoliuliu/ABSherlockSlides
Vurgular:
Büyük bir cihazın çekmece her zaman görünür olduğundan, bir çekmece var gerek yok. Bunun yerine, aynı ada sahip iki öğe ile bir LinearLayout yeterli olacaktır.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ListView
android:id="@ id/listview_drawer"
android:layout_width="@dimen/drawer_size"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="@color/drawer_background"/>
<FrameLayout
android:id="@ id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/drawer_content_padding"
/>
</LinearLayout>
App düzeni içinde eleman bulmak için çalıştığınızda düzeni dosyasında çekmece var, ama bizde yok çünkü, boş döner. Bu yüzden, fazladan bir boolean kullanarak görmeye gerek yok.
DrawerLayout mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
if (mDrawerLayout != null) {
// Set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// Enable ActionBar app icon to behave as action to toggle nav drawer
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// ActionBarDrawerToggle ties together the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(
this,
mDrawerLayout,
R.drawable.ic_drawer,
R.string.drawer_open,
R.string.drawer_close) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}
public void onDrawerOpened(View drawerView) {
// Set the title on the action when drawer open
getSupportActionBar().setTitle(mDrawerTitle);
super.onDrawerOpened(drawerView);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
Burada boolean olarak kullanmak için örnek.
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (mDrawerLayout != null) {
mDrawerToggle.syncState();
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (mDrawerLayout != null) {
// Pass any configuration change to the drawer toggles
mDrawerToggle.onConfigurationChanged(newConfig);
}
}
Navigasyon Çekmece yarı saydam Durum Ç...
Navigasyon Çekmece (Google, YouTube vs...
Mac OS X Lion üzerinde ortam değişkenl...
Android: odak bir EditText üzerinde yu...
Nasıl kalıcı olarak Linux üzerinde set...