이것은 내 첫 번째 스택 오버 플로우 문제입니다. 내가 충분히 추가하지 않으면 나에게 벌거 벗은 채로 또는 너무 자세하게 추가한다.Android Overflow 메뉴가 작업 표시 줄/툴바 위에 위치합니까?
오버플로 메뉴를 내 앱의 상단 표시 줄 아래에 표시하려고합니다. Holo 테마를 사용했을 때이 작업은 훌륭하게 수행되었지만 appcompat v7 라이브러리를 사용하여 재질 디자인을 사용하도록 내 앱을 설정하려고합니다.
<?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>
을 그리고이 제대로이 레이아웃 내 도구 모음에 소재 디자인 테마를 적용 않습니다 :
그래서 내 주제는 지금 APPCOMPAT에서 확장
<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>
그러나 어떤 이유로, 메뉴 I onCreateOptionsMenu에서 inflate하면 잘못된 위치에 나타납니다. 분명히 이미지를 게시 할 수 없지만 기본적으로 오버플로 메뉴는 툴바 바로 아래에 표시되는 대신 툴바를 덮습니다. 이것은 정상적인 ActionBar에서 먼저 "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