Android DialogFragment wrap_content不起作用

时间:2015-12-12 21:54:50

标签: android android-dialogfragment android-wrap-content

PopupDialog扩展了DialogFragment;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.lyt_dialog_popup, container, false);
        _work();
    return view;
} 

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

lyt_dialog_popup.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width ="match_parent"
                android:layout_height="wrap_content">

    <include
        android:id="@+id/dialogPopupToolbar"
        layout="@layout/toolbar"/>

    <include
        layout="@layout/rcy_list"
        android:id="@+id/dialogPopupList"
        android:layout_below="@id/dialogPopupToolbar"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_margin="5dp"/>

</RelativeLayout>

toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/primaryColor"/>

rcy_list.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

所有代码都运行良好,但只有布局wrap_content无法正常工作。我怎么能解决这个问题?

0 个答案:

没有答案