यह मेरा पहला स्टैक ओवरफ़्लो प्रश्न है। मेरे साथ सावधान रहें यदि मैं पर्याप्त नहीं जोड़ता या मैं बहुत अधिक विस्तार जोड़ता हूं।एंड्रॉइड ओवरफ्लो मेनू एक्शनबार/टूलबार के ऊपर स्थित है?
मैं अपने ऐप में शीर्ष बार के नीचे दिखाई देने के लिए अपना ओवरफ़्लो मेनू प्राप्त करने का प्रयास कर रहा हूं। जब मैं होलो थीम का उपयोग कर रहा था तो यह ठीक था, लेकिन मैं ऐपकंपैट v7 लाइब्रेरी का उपयोग करके भौतिक डिज़ाइन का उपयोग करने के लिए अपना ऐप प्राप्त करने की कोशिश कर रहा हूं।
तो मेरी विषय अब AppCompat से लागू होता है:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/ucla_blue</item>
<item name="colorAccent">@color/caldroid_white</item>
<item name="android:actionMenuTextColor">@color/caldroid_black</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
और यह ठीक से इस लेआउट में मेरी टूलबार में सामग्री डिजाइन विषय लागू होता है:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearlayout_root_main"
android:layout_height="match_parent"
android:layout_width="match_parent">
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context="com.ucla.ieee.app.MainActivity">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/colorPrimary"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="@+id/container"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</LinearLayout>
<!-- The navigation drawer -->
<fragment
android:id="@+id/navigation_drawer"
android:layout_gravity="start"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_width="@dimen/navigation_drawer_width"
android:name="navigation.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer"/>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
लेकिन किसी कारण से, मेनू मैं CrateOptionsMenu में बढ़ोतरी गलत जगह पर दिखाई देता है। जाहिर है, मैं छवियों को पोस्ट नहीं कर सकता लेकिन मूल रूप से ओवरफ्लो मेनू टूलबार के नीचे दिखाई देने के बजाय टूलबार को कवर करता है। यह तब शुरू हो रहा था जब मैं "Theme.AppCompat" का उपयोग पहले सामान्य एक्शनबार में और अब भी टूलबार के साथ करता हूं।
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
switch (selected) {
case FRONT_PAGE:
toolbar.inflateMenu(R.menu.main_settings);
return false;
case ANNOUNCEMENTS:
toolbar.inflateMenu(R.menu.refresh_settings);
return false;
case MEMBERSHIP:
toolbar.inflateMenu(R.menu.edit_member);
return false;
case CALENDAR:
toolbar.inflateMenu(R.menu.refresh_settings);
return false;
case POINTS_REWARDS:
toolbar.inflateMenu(R.menu.main_settings);
return false;
case HELP:
toolbar.inflateMenu(R.menu.main_settings);
return false;
default:
toolbar.inflateMenu(R.menu.main_settings);
}
किसी को यह भी अनुभव करने में प्रतीत नहीं होता है, मुझे आशा है कि कोई मुझे यह समझने में मदद कर सकता है! धन्यवाद!
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.ucla_ieee.app.MainActivity">
<item android:id="@+id/action_refresh"
android:title="@string/action_refresh"
app:showAsAction="never" />
</menu>
धन्यवाद लेकिन मैं पहले से ही अपनी मुख्य गतिविधि में ऐसा कर रहा हूं। ऐसा नहीं है कि मेनू काम नहीं करता है, यह सिर्फ गलत दिखता है: http://i.imgur.com/0ybW1A9.png – Tania
मेरा स्क्रीनशॉट दिए गए मेरे उत्तर को अपडेट किया गया: आप जो देख रहे हैं वह एक सामग्री डिज़ाइन मेनू है। – ianhanniballake
ओह डर्न, मेरे द्वारा लागू किए गए ऐप्स का अनुमान लगाएं मैटेरियल डिज़ाइन ने मुझे गलत विचार दिया है। धन्यवाद!! – Tania