【问题标题】:White rectangle on top of DialogFragmentDialogFragment 顶部的白色矩形
【发布时间】:2016-01-30 21:46:46
【问题描述】:

使用 dialogFragment 时,我在片段顶部得到一个空白矩形,但不知道为什么。

我应该得到什么

我实际上得到了什么

我的 DialogFragment:

 public class SelectDialogFragment extends DialogFragment {

            @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            //inflate layout with recycler view
            View v = inflater.inflate(R.layout.select_frag, container, false);
            return v;
        }

}

select_frag.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:orientation="vertical"
    android:background="#000"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="New Text"
        android:id="@+id/textView" />
</RelativeLayout>

【问题讨论】:

    标签: android android-studio


    【解决方案1】:

    你应该设置没有标题的样式:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NO_TITLE, 0);
    }
    

    您还可以找到更多有用的示例here

    【讨论】:

    • 我没有指定任何特定的主题
    • 哦,是的,你应该设置STYLE_NO_TITLE样式。
    • 可惜白条还在
    猜你喜欢
    • 1970-01-01
    • 2019-07-29
    • 1970-01-01
    • 2020-09-28
    • 2021-02-19
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多