2014-10-18 4 views
6

मैं एपकोपैट v7 लाइब्रेरीज़ का उपयोग करके अपने ऐप के एक भौतिक डिज़ाइन संस्करण पर काम कर रहा हूं, और मैंने नेविगेशन ड्रॉवर के साथ कोई समस्या मारा है। जब यह खुलता है, तो सामग्री डिज़ाइन टूलबार में बटन कार्य करना बंद कर देते हैं - नेविगेशन ड्रॉवर के बाहर कोई भी स्पर्श केवल दराज को बंद कर देता है।जब कोई नेविगेशन ड्रॉवर खुला रहता है तो टूलबार बटन स्पर्श करने का जवाब नहीं देते हैं

<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_parent" 
    android:layout_height="match_parent"> 

    <!-- The main content view --> 
    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/action_toolbar" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:minHeight="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      android:elevation="4dp" 
      /> 

     <FrameLayout 
      android:id="@+id/note_list_container" 
      android:layout_marginTop="?attr/actionBarSize" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

     <net.rymate.notes.ui.FloatingActionButton 
      android:id="@+id/fabbutton" 
      android:layout_width="72dp" 
      android:layout_height="72dp" 
      android:layout_gravity="bottom|right" 
      android:layout_marginBottom="16dp" 
      android:layout_marginRight="16dp" /> 
    </FrameLayout> 
    <!-- The navigation drawer --> 
    <LinearLayout 
     android:id="@+id/left_drawer" 
     android:layout_width="300dp" 
     android:layout_marginTop="?attr/actionBarSize" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:orientation="vertical"> 

     <ListView 
      android:id="@+id/cat_list" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:choiceMode="singleChoice" 
      android:divider="@android:color/transparent" 
      android:dividerHeight="0dp" 
      android:background="?catBackColour" /> 
    </LinearLayout> 

</android.support.v4.widget.DrawerLayout> 

यहाँ और onCreate कोड है कि दराज और initialises है: एक निम्नलिखित है XML लेआउट मैं गतिविधि के लिए उपयोग कर रहा हूँ मैं क्या मतलब

the gif http://images.rymate.co.uk/images/83JXi1X.png

यहाँ की एक gif है उपकरण पट्टी।

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    ROBOTO_LIGHT = Typeface.createFromAsset(this.getAssets(), "Roboto-Light.ttf"); 
    ROBOTO_LIGHT_ITALICS = Typeface.createFromAsset(this.getAssets(), "Roboto-LightItalic.ttf"); 

    setContentView(R.layout.activity_notes); 

    if (findViewById(R.id.note_container) != null) { 
     // The detail container view will be present only in the 
     // large-screen layouts (res/values-large and 
     // res/values-sw600dp). If this view is present, then the 
     // activity should be in two-pane mode. 
     mTwoPane = true; 

     // In two-pane mode, list items should be given the 
     // 'activated' state when touched. 
     FragmentManager fm = getSupportFragmentManager(); 
     //list.setActivateOnItemClick(true); 
    } 


    if (!mTwoPane) { 
     final FloatingActionButton mFab = (FloatingActionButton) findViewById(R.id.fabbutton); 
     mFab.init(Color.parseColor("#1e90ff")); 
     mFab.setFabDrawable(getResources().getDrawable(R.drawable.ic_action_new)); 
     mFab.showFab(); 

     mFab.setOnClickListener(this); 

     list = new NotesListFragment(mFab); 
    } else { 
     list = new NotesListFragment(); 
    } 


    Toolbar toolbar = (Toolbar) findViewById(R.id.action_toolbar); 
    setSupportActionBar(toolbar); 

    getSupportFragmentManager().beginTransaction() 
      .replace(R.id.note_list_container, list) 
      .commit(); 

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // the layout 
    mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer); 

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); 

    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

    getSupportActionBar().setHomeButtonEnabled(true); 

    mDrawerLayout.setScrimColor(getResources().getColor(android.R.color.transparent)); 

    mDrawerToggle = new ActionBarDrawerToggle(
      this,     /* host Activity */ 
      mDrawerLayout,   /* DrawerLayout object */ 
      toolbar, /* toolbar */ 
      R.string.drawer_open, /* "open drawer" description */ 
      R.string.drawer_close /* "close drawer" description */ 
    ) { 

     /** Called when a drawer has settled in a completely closed state. */ 
     public void onDrawerClosed(View view) { 
      getSupportActionBar().setTitle("Rymate Notes"); 
      supportInvalidateOptionsMenu(); 
     } 

     /** Called when a drawer has settled in a completely open state. */ 
     public void onDrawerOpened(View drawerView) { 
      getSupportActionBar().setTitle("Categories"); 
      supportInvalidateOptionsMenu(); 
     } 
    }; 

    // Set the drawer toggle as the DrawerListener 
    mDrawerLayout.setDrawerListener(mDrawerToggle); 

    pref = getSharedPreferences("rymatenotesprefs", MODE_PRIVATE); 

    mDrawerList = (ListView) findViewById(R.id.cat_list); 

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); 

    mDbHelper = new NotesDbAdapter(this); 
    mDbHelper.open(); 

    if (mDbHelper.fetchAllNotes().getCount() == 0) { 
     IntroFragment fragment = new IntroFragment(); 
     getSupportFragmentManager().beginTransaction() 
       .replace(R.id.note_list_container, fragment) 
       .commit(); 

    } 

    getCategories(); // calls a function which populates the listview 

} 

क्या संभवतः इसे ठीक करने का कोई तरीका है?

+1

सामग्री डिजाइन कल्पना का कहना है कि नेविगेशन ड्रॉर टूलबार पर और प्रस्थिति के तहत होना चाहिए, और उस मामले में बटन जवाब नहीं के व्यवहार सही समझ में आता है। यहां एक नज़र डालें: http://www.google.com/design/spec/patterns/navigation-drawer.html –

उत्तर

1

निकोला देस्पोटोसकी के पास सही विचार था - टच इवेंट ड्रॉवरवेआउट द्वारा चुराया गया था। हालांकि बजाय स्पर्श घटना में अवरोध डालने की मैं सिर्फ इतना की तरह गतिविधि लेआउट समायोजित:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/action_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" 
     android:elevation="4dp" 
     android:minHeight="?attr/actionBarSize" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="?attr/actionBarSize" > 

     <!-- The main content view --> 
     <FrameLayout 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <FrameLayout 
       android:id="@+id/note_list_container" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"/> 

      <net.rymate.notes.ui.FloatingActionButton 
       android:id="@+id/fabbutton" 
       android:layout_width="72dp" 
       android:layout_height="72dp" 
       android:layout_gravity="bottom|right" 
       android:layout_marginBottom="16dp" 
       android:layout_marginRight="16dp" /> 
     </FrameLayout> 
     <!-- The navigation drawer --> 
     <LinearLayout 
      android:id="@+id/left_drawer" 
      android:layout_width="300dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:orientation="vertical"> 

      <ListView 
       android:id="@+id/cat_list" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="?catBackColour" 
       android:choiceMode="singleChoice" 
       android:divider="@android:color/transparent" 
       android:dividerHeight="0dp" /> 
     </LinearLayout> 

    </android.support.v4.widget.DrawerLayout> 
</FrameLayout> 

यह इजाजत दी स्पर्श इवेंट Toolbar बजाय DrawerLayout द्वारा पंजीकृत होने के लिए की इच्छित प्रभाव पड़ता है।

+10

इसलिए आपने किसी अन्य सुझाव के आधार पर अपने स्वयं के प्रश्न का उत्तर लिखा और फिर अपना जवाब स्वीकार कर लिया? और अपने उत्तर को भी ऊपर उठाया या स्वीकार नहीं किया? – VipulKumar

+0

यह समझना मुश्किल है कि आपके लेआउट में कौन सा परिवर्तन टूलबार से ड्रॉवर स्टॉप इंटरसेप्टिंग टच इवेंट बना देता है ... – Marek

11

, लगता है कि स्पर्श घटना दराज की छाया द्वारा चोरी हो जाता है, यानी DrawerLayout स्पर्श इवेंट में अवरोध उत्पन्न कर रखता है क्योंकि Toolbar, सामग्री को देखने का हिस्सा है के विपरीत ActionBar सजावट दृश्य के शीर्ष पर जा रहा है।

संभव काम के आसपास स्पर्श घटना में अवरोध उत्पन्न कर रहा है:

यह 0 (ऊपर) और Toolbar ऊंचाई (नीचे) के बीच है, तो Toolbar वस्तु को सीधे घटना प्रेषण। अन्यथा सामान्य व्यवहार रखें।

दराज टॉगल क्लिक के लिए एक ही मामला है?

संबंधित मुद्दे