SORU
16 HAZİRAN 2013, Pazar


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

enter image description here

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
25 EYLÜL 2013, ÇARŞAMBA


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);
    }
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • apenney888

    apenney888

    27 EKİM 2010
  • Eric Anthony

    Eric Anthony

    13 AĞUSTOS 2011
  • Jason Rosolowski

    Jason Rosolo

    25 EKİM 2006