Я создал меню и всплывающее меню, как картинка ниже (я получаю в Интернете и редактирую краска), я не знаю, почему она не отображает нормальный http://i.imgur.com/jHPobCH.png. Мне нужен интерфейс вроде этого http://i.imgur.com/08XomVV.png и moever, как мне изменить цвет фона всплывающего меню? Я пробовал, как показано ниже, но не успел. Я тестирую Samsung Galaxy J и Android 4.4.2.Android - Всплывающее меню не отображается под панелью действий меню
MainActivity.java
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_filter"
android:icon="@drawable/ic_filter_white_18dp"
android:title="@string/action_filter"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_label"
android:icon="@drawable/ic_add_circle_outline_white_18dp"
android:title="@string/action_label"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_filter"
android:icon="@drawable/ic_filter_white_18dp"
android:title="@string/action_filter"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_label"
android:icon="@drawable/ic_add_circle_outline_white_18dp"
android:title="@string/action_label"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:background">#3079EB</item>
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
P/S: Я начинающий андроида развитие это
Вы получили решение выше? Я застрял в этой проблеме. Если вы получите правильное решение, то помогите мне. – Vasant