我的弹出窗口仍然没有背景。 我想要一个白色的弹出窗口,说谁赢了比赛。
爪哇:
LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
PopupWindow pw = new PopupWindow(layoutInflater.inflate(R.layout.winner_popup,null, false), LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
pw.showAtLocation(findViewById(R.id.main_layout), Gravity.CENTER, 0, 0);
TextView winnerText = (TextView) pw.getContentView().findViewById(R.id.winnerTextView);
winnerText.setText("Player 1 is the winner"); //Update the TextView
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white">
<TextView
android:id="@+id/winnerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/winnerTextViewString"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/winnerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/winnerButtonString"
android:layout_marginLeft="45dp"/>
</LinearLayout>
是否可以或者我应该使用警报窗口?
溴