Sie können Sie für diese PopupWindow, überprüfen Sie den Code unten:
pop_layout.xml
<LinearLayout 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"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="22dp"
android:text="Item 1"
android:id="@+id/one"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:id="@+id/two"
android:layout_marginTop="22dp"
android:text="Item 2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="22dp"
android:text="Item 3"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/four"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="22dp"
android:text="Item 4"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
PopupWindow:
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View popupView = layoutInflater.inflate(R.layout.pop_layout, null);
TextView one = (TextView)popupView.findViewById(R.id.one);
TextView two = (TextView)popupView.findViewById(R.id.two);
TextView three = (TextView)popupView.findViewById(R.id.three);
TextView four = (TextView)popupView.findViewById(R.id.four);
// Do your customised stuff
PopupWindow popupWindow = new PopupWindow(
popupView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
//TODO do sth here on dismiss
}
});
popupWindow.showAsDropDown(view);// your view instance in which click you want to show menu
i Lösung Ihrer Frage auf diesem Link bitte überprüfen. http://StackOverflow.com/Questions/26957925/how-to-change-popupmenu-items-font –
Mögliche Duplikate von [Wie PopupMenu Elemente Schriftart ändern] (http://StackOverflow.com/questions/26957925/how -zu-ändern-popupmenu-artikel-schriftart) – iled