0

我有BottomSheetDialogBottomSheetDialogFragment一个布局:

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="350dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="@color/colorPrimary"
        app:expandedTitleMargin="16dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:statusBarScrim="@color/colorPrimaryDark"
        app:title="Roman R">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="48dp"
            app:layout_collapseMode="parallax"
            app:srcCompat="@drawable/ic_person_white_24dp" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            style="@style/AppTheme.ToolBarStyle"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin" />
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackground"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <include layout="@layout/profile_info" />

</android.support.v4.widget.NestedScrollView>

两者都增加了额外的上边距,这等于Toolbar高度。看起来像:

在此处输入图像描述 在此处输入图像描述

我的BottomSheetDialogFragment

public class ContactBottomSheet extends BottomSheetDialogFragment {

    @BindView(R.id.collapsing_toolbar)
    public CollapsingToolbarLayout collapsingToolbarLayout;

    private User user;

    @Override
    public void setupDialog(final Dialog dialog, int style) {
        View rootView = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet_contact, null);
        ButterKnife.bind(this, rootView);

        refreshUI();

        dialog.setContentView(rootView);
//        super.setupDialog(dialog, style);
    }

    private void refreshUI() {
        if (getUser() == null) {
            return;
        }

        collapsingToolbarLayout.setTitle(getUser().getName());
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}

我创建这样的对话框:

 ContactBottomSheet dialog = new ContactBottomSheet();
        dialog.show(getSupportFragmentManager(), "ContactBottomSheet");

请帮忙,因为我不知道。

4

2 回答 2

1

当你使用

app:expandedTitleMargin="16dp"

android:padding="48dp"

这使您的上边距为 64dp

解决方案:-

减少这个并运行

于 2016-08-10T20:39:05.360 回答
0

尝试将其添加到末尾。

var bottomSheet = FindViewById<FrameLayout>(Resource.Id.design_bottom_sheet);
BottomSheetBehavior.From(bottomSheet).State = BottomSheetBehavior.StateExpanded;
于 2018-09-10T08:45:20.680 回答