popupmenu
android popup menu text color (AppCompat)
In styles.xml <style name=”itemTextStyle.AppTheme” parent=”@android:style/TextAppearance.Widget.IconMenu.Item”> <item name=”android:textColor”>@drawable/color_item_popup</item> <item name=”android:textSize”>@dimen/text_content</item> </style> and add in AppTheme <item name=”android:itemTextAppearance”>@style/itemTextStyle.AppTheme</item> color_item_popup.xml <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_pressed=”true” android:color=”@color/primary_text”/> <item android:state_focused=”true” android:color=”@color/primary_text”/> <item android:color=”@color/secondary_text”/> </selector>
Show popup menu on `ActionBar` item click
So finally I found solution. When you want to anchor popupmenu to ActionItem in ActionBar you need to find view that renders ActionItem. Simple find view with findViewById() where id is same as id of your menu item in xml. DISPLAYING POPUP: public boolean onOptionsItemSelected(MenuItem item) { // … View menuItemView = findViewById(R.id.menu_overflow); // SAME … Read more
What’s the name of the little widget with three dots inside a cardview in android?
This is not a widget at all. It is an ImageButton (borderless in style) using the overflow Icon that includes a PopupMenu For documentation tutorial visits http://developer.android.com/guide/topics/ui/menus.html#PopupMenu This refers to a nice code snippet from the link above: <ImageButton android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”https://stackoverflow.com/questions/31765395/@drawable/ic_overflow_holo_dark” android:contentDescription=”@string/descr_overflow_button” android:onClick=”showPopup” /> Then use to show popup: public void showPopup(View v) { … Read more
PopupMenu with icons [duplicate]
This way works if you’re using AppCompat v7. It’s a little hacky but significantly better than using reflection and lets you still use the core Android PopupMenu: PopupMenu menu = new PopupMenu(getContext(), overflowImageView); menu.inflate(R.menu.popup); menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { … }); MenuPopupHelper menuHelper = new MenuPopupHelper(getContext(), (MenuBuilder) menu.getMenu(), overflowImageView); menuHelper.setForceShowIcon(true); menuHelper.show(); res/menu/popup.xml <?xml version=”1.0″ encoding=”utf-8″?> <menu xmlns:android=”http://schemas.android.com/apk/res/android”> … Read more
Android custom dropdown/popup menu
Update: To create a popup menu in android with Kotlin refer my answer here. To create a popup menu in android with Java: Create a layout file activity_main.xml under res/layout directory which contains only one button. Filename: 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:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin” tools:context=”.MainActivity” > <Button android:id=”@+id/button1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:layout_alignParentTop=”true” … Read more