Java BottomSheetDialogFragment设置峰值和其他行为
我想底部屏幕偷看,然后采取了全屏幕时,滑了起来。目前,当我按下“按钮1”时,它会显示出来,因为我无法让窥视开始工作 但是,我可以将其向上滑动,使其占据整个屏幕。理想情况下,它会自动执行此操作 当我把它滑下来的时候,它会一直滑下去 我想要以下行为:Java BottomSheetDialogFragment设置峰值和其他行为,java,android,android-layout,android-fragments,material-design,Java,Android,Android Layout,Android Fragments,Material Design,我想底部屏幕偷看,然后采取了全屏幕时,滑了起来。目前,当我按下“按钮1”时,它会显示出来,因为我无法让窥视开始工作 但是,我可以将其向上滑动,使其占据整个屏幕。理想情况下,它会自动执行此操作 当我把它滑下来的时候,它会一直滑下去 我想要以下行为: 底部板材应始终窥视300dp或任何东西 在底部纸张上向上滑动会导致它占据全屏视图,如第二张图片所示 向下滑动底部板材时,应回到其窥视高度 我不知道如何控制底部工作表行为,因为BottomSheetBehavior类似乎只适用于XML中定义的那些
300dp
或任何东西BottomSheetBehavior
类似乎只适用于XML中定义的那些
活动\u main.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<Button
android:id="@+id/button_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1"
android:padding="16dp"
android:layout_margin="8dp"
android:textColor="@android:color/white"
android:background="@android:color/holo_green_dark"/>
// ...
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:background="@android:color/holo_orange_light"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Some text..."
android:padding="16dp"
android:textSize="16sp"/>
</RelativeLayout>
TestBottomSheetDialogFragment.java
package com.example.qqq.bottomsheets;
import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private BottomSheetBehavior mBottomSheetBehavior;
private TestBottomSheetDialogFragment mTestBottomSheetDialogFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = (Button) findViewById( R.id.button_1 );
Button button2 = (Button) findViewById( R.id.button_2 );
Button button3 = (Button) findViewById( R.id.button_3 );
mTestBottomSheetDialogFragment = new TestBottomSheetDialogFragment();
button1.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.button_1: {
mTestBottomSheetDialogFragment.show(getSupportFragmentManager(), mTestBottomSheetDialogFragment.getTag());
break;
}
}
}
}
package com.example.qqq.bottomsheets;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class TestBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return super.onCreateDialog(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bottom_sheet, container, false);
return view;
}
}
你找到这个案子的解决办法了吗?