我有一个我希望半透明的对话框实际上是完全透明的。
Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent);
dialog.setContentView(R.layout.scores);
ListView lvw = (ListView)dialog.getWindow().findViewById(R.id.lvwScores);
LayoutInflater inflater = this.getLayoutInflater();
View footerView = inflater.inflate(R.layout.playerscorestotals, null);
((TextView) footerView.findViewById(R.id.tvwPlayer1Total)).setText(String.valueOf(totalsCursor.getInt(totalsCursor.getColumnIndex("player1Total"))));
((TextView) footerView.findViewById(R.id.tvwPlayer2Total)).setText(String.valueOf(totalsCursor.getInt(totalsCursor.getColumnIndex("player2Total"))));
((TextView) footerView.findViewById(R.id.tvwPlayer3Total)).setText(String.valueOf(totalsCursor.getInt(totalsCursor.getColumnIndex("player3Total"))));
lvw.addFooterView(footerView);
((TextView) dialog.findViewById(R.id.tvwPlayer1Name)).setText(players[1].playerName);
((TextView) dialog.findViewById(R.id.tvwPlayer2Name)).setText(players[2].playerName);
((TextView) dialog.findViewById(R.id.tvwPlayer3Name)).setText(players[3].playerName);
lvw.setAdapter(new SimpleCursorAdapter(this, R.layout.playerscoresrow, scoresCursor,
new String[] {"_id","player0Score","player1Score",
"player2Score","player3Score"},
new int[] {R.id.tvwGameNumber,R.id.tvwPlayer0Score, R.id.tvwPlayer1Score,
R.id.tvwPlayer2Score, R.id.tvwPlayer3Score }
));
scores.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/tvwGameOver" android:layout_weight="1" android:gravity="center"
android:textSize="25sp" android:visibility="gone"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:footerDividersEnabled="true"
android:headerDividersEnabled="true" android:layout_below="@id/tvwGameOver">
<TextView
android:id="@+id/tvwGameNumberHeader" android:layout_weight="1" android:gravity="right"
android:text="@string/scores_GameNumber" android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer0Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
</LinearLayout>
<ListView
android:id="@+id/lvwScores" android:layout_below="@id/lloPlayerNames"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:divider="#FFFFFF" android:dividerHeight="1dip"
android:footerDividersEnabled="true" android:headerDividersEnabled ="true"/>
<Button android:id="@+id/btnOK"
android:layout_height="wrap_content" android:layout_width="120dip"
android:layout_weight="1"
android:text="OK" android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
playerscorestotals.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:id="@+id/tvwTotalHeader" android:layout_weight="1" android:gravity="left" android:text="Total:"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<TextView android:id="@+id/tvwPlayer0Total" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
<TextView android:id="@+id/tvwPlayer1Total" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
<TextView android:id="@+id/tvwPlayer2Total" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
<TextView android:id="@+id/tvwPlayer3Total" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
</LinearLayout>
playerscoresrow.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView android:id="@+id/tvwGameNumber" android:layout_weight="1" android:gravity="center_horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<TextView android:id="@+id/tvwPlayer0Score" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
<TextView android:id="@+id/tvwPlayer1Score" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
<TextView android:id="@+id/tvwPlayer2Score" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
<TextView android:id="@+id/tvwPlayer3Score" android:layout_weight="1" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"/>
</LinearLayout>