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