2
フルスクリーンを作成しようとしていますが(ステータスバーはまだ表示されています)カスタム透明のダイアログ(この回答はhttps://stackoverflow.com/a/29482234と同じですが)は背景が透明ではありません。透明な背景を持つDialogFragment
すべてのソリューションを試しても無駄な2日間でしたが、機能しません。私の目標は、デフォルトの黒ではなくカスタムの薄暗い色のダイアログを表示することです。上記の答えは私が必要としたように見えましたが、私はそれを働かせることはできません。助言がありますか?
マイコード:
<style name="CustomDialogTheme2" parent="@android:style/Theme.Dialog">
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
レイアウト:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AAFFFFFF">
<RelativeLayout
android:id="@+id/dialog_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="#CCFF0000"
android:padding="16dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</RelativeLayout>
</FrameLayout>
DialogFragment:
public class TestDialogFrag extends DialogFragment {
public static TestDialogFrag newInstance() {
Bundle args = new Bundle();
TestDialogFrag fragment = new TestDialogFrag();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.CustomDialogTheme2);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.test_dialog_frag, container, false);
return view;
}
}
あなたはこれを試みましたか? @ fanboy555 – MathaN