无法将底部对话框放置在屏幕底部

时间:2019-08-04 20:32:25

标签: android dialog fragment bottom-sheet

我有一个“视频详细信息片段”,我想将其作为最底下的行为,但是很遗憾,该对话框显示在屏幕中央。我无法找出代码中的确切问题。下面,我附上关于它们的代码和布局文件。

这是我的视频详细信息片段:

public class VideoDetailsFragment extends BottomSheetDialogFragment {

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AppCompatDialog dialog = new AppCompatDialog(getActivity());
    dialog.setTitle(titleId);
    return dialog;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View dialogView = inflater.inflate(R.layout.video_detail_fragment, container, false);
    Button cancelButton = dialogView.findViewById(R.id.track_selection_dialog_cancel_button);
    Button okButton = dialogView.findViewById(R.id.track_selection_dialog_ok_button);

    return dialogView;
}

public static final class TrackSelectionViewFragment extends BottomSheetDialogFragment
        implements TrackSelectionView.TrackSelectionListener {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.exo_track_selection_dialog, container, /* attachToRoot= */ false);
        TrackSelectionView trackSelectionView = rootView.findViewById(R.id.exo_track_selection_view);
        trackSelectionView.setShowDisableOption(true);
        trackSelectionView.setAllowMultipleOverrides(allowMultipleOverrides);
        trackSelectionView.setAllowAdaptiveSelections(allowAdaptiveSelections);
        trackSelectionView.init(mappedTrackInfo, rendererIndex, isDisabled, overrides, /* listener= */ this);
        return rootView;
        }

    }

}

video_detail_fragment的xml文件:

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="270dp"
    android:visibility="visible"
    app:behavior_hideable="true"
    app:behavior_peekHeight="0dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
    >

    <FrameLayout
        android:id="@+id/child_fragment_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="end">

    </LinearLayout>

</LinearLayout>

我浏览了许多帖子,但是几乎所有帖子都显示了设置app属性app:layout_behavior="android.support.design.widget.BottomSheetBehavior"的解决方案。但这对我来说不起作用。请帮助我了解我在哪里做错了吗?

0 个答案:

没有答案