I want to show a popup dialog with a text message but the formatting does not work.
I want it to be in the center of the popup and with specific font but neither is applied.
My code:
AlertDialog dialog = new AlertDialog.Builder(context).create();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
View view = LayoutInflater.from(mContext).inflate(R.layout.my_view, null);
dialog.setView(view);
TextView messageView = (TextView) view.findViewById(R.id.message);
messageView.setTextIsSelectable(true);
messageView.setText("This is the message to show");
dialog.show();
And the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal"
android:background="@color/red"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textSize="14sp"/>
</LinearLayout>
What is the problem here?
create layout
create dialog