Android Jelly Beans OS でアラート ダイアログを作成しています。すべてがうまく機能しますが、私が望むのは、警告ダイアログの黒い背景の代わりに透明な背景が欲しいということです。stackoverflow に関する非常に多くの記事とユーザーの質問を読みましたが、どれも私を助けてくれませんでした。
これが私のコードです:
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.CustomAlertDialog);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog1, int which) {
gActivityResult = REQUEST_PICK_CONTACT;
onResume();
return;
} });
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog1, int which) {
return;
} });
View view = getLayoutInflater().inflate(R.layout.alert_dialog, null);
builder.setTitle(R.string.gender_age);
builder.setInverseBackgroundForced(false);
builder.setView (view);
dialog = builder.create ();
res/values/styles.xml で定義されている私の CustomAlertDialog は次のとおりです。
<style name="CustomAlertDialog" parent="@android:style/Theme.Dialog">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowBackground">@color/transparent_color</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:gravity">left</item>
</style>
ここにcolor.xmlがあります
<resources>
<color name="transparent_color">#00000000</color>
</resources>
しかし、それは私を助けませんでした。
私の質問: これは実行可能ですか? はいの場合、正しい方向に私を案内してもらえますか?