2016-11-01 2 views
2

아래쪽 시트가 완전히 위로 올라간 다음 (전체 화면으로 끌 때까지) 뷰를 아래로 스크롤하고 싶습니다. 그것은 위로 스크롤 할 때 좋은 작동하지만 아래로 스크롤 할 때 작동하지 않습니다. 오히려 바닥 시트 전체가 아래로 내려옵니다. 어떤 출구?아래쪽 시트에서 아래로 스크롤 작업

주요 활동

import android.os.Bundle; 
import android.support.design.widget.BottomSheetBehavior; 
import android.support.design.widget.BottomSheetDialog; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.util.TypedValue; 
import android.view.View; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.widget.Button; 

public class MainActivity extends AppCompatActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     Button fab = (Button) findViewById(R.id.button); 
     fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this); 
       View parentView = getLayoutInflater().inflate(R.layout.sheetlayout,null); 
       bottomSheetDialog.setContentView(parentView); 
       BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) parentView.getParent()); 
       bottomSheetBehavior.setPeekHeight(
         (int) TypedValue.applyDimension(
           TypedValue.COMPLEX_UNIT_DIP,100,getResources().getDisplayMetrics() 
         ) 
       ); 
       bottomSheetDialog.show(); 

      } 
     }); 
    } 
} 

SheetLayout.xml

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <Button 
     android:text="button1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button1" /> 

    <Button 
     android:text="button2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button2" /> 

    <Button 
     android:text="button3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button3" /> 

    <Button 
     android:text="button4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button4" /> 

    <Button 
     android:text="button5" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button5" /> 

    <Button 
     android:text="button6" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button18" /> 

    <Button 
     android:text="button7" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button7" /> 

    <Button 
     android:text="button8" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button8" /> 

    <Button 
     android:text="button9" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button9" /> 

    <Button 
     android:text="button10" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button10" /> 

    <Button 
     android:text="button11" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button11" /> 

    <Button 
     android:text="button12" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button12" /> 

    <Button 
     android:text="button13" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button13" /> 

    <Button 
     android:text="button14" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button14" /> 

    <Button 
     android:text="button15" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button15" /> 

    <Button 
     android:text="button16" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button16" /> 

    <Button 
     android:text="button17" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button17" /> 

    <Button 
     android:text="button18" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/button6" /> 
</LinearLayout> 
    </ScrollView> 

EDIT1

<?xml version="1.0" encoding="utf-8"?> 


<ScrollView 
    android:layout_height="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"> 

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <Button 
      android:text="button1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button1" /> 

     <Button 
      android:text="button2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button2" /> 

     <Button 
      android:text="button3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button3" /> 

     <Button 
      android:text="button4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button4" /> 

     <Button 
      android:text="button5" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button5" /> 

     <Button 
      android:text="button6" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button18" /> 

     <Button 
      android:text="button7" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button7" /> 

     <Button 
      android:text="button8" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button8" /> 

     <Button 
      android:text="button9" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button9" /> 

     <Button 
      android:text="button10" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button10" /> 

     <Button 
      android:text="button11" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button11" /> 

     <Button 
      android:text="button12" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button12" /> 

     <Button 
      android:text="button13" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button13" /> 

     <Button 
      android:text="button14" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button14" /> 

     <Button 
      android:text="button15" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button15" /> 

     <Button 
      android:text="button16" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button16" /> 

     <Button 
      android:text="button17" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button17" /> 

     <Button 
      android:text="button18" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button6" /> 
    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 
    </ScrollView> 

Edit2가

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.CoordinatorLayout 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="match_parent"> 

    <ScrollView 
     android:layout_width="match_parent" 
     app:layout_behavior="android.support.design.widget.BottomSheetBehavior" 
     android:layout_height="match_parent"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     > 

     <Button 
      android:text="@string/button1" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:id="@+id/button1" 
      android:layout_weight="0.66" /> 

     <Button 
      android:text="button2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button2" /> 

     <Button 
      android:text="button3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button3" /> 

     <Button 
      android:text="button4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button4" /> 

     <Button 
      android:text="button5" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button5" /> 

     <Button 
      android:text="button6" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button18" /> 

     <Button 
      android:text="button7" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button7" /> 

     <Button 
      android:text="button8" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button8" /> 

     <Button 
      android:text="button9" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button9" /> 

     <Button 
      android:text="@string/button10" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button10" /> 

     <Button 
      android:text="@string/button11" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button11" /> 

     <Button 
      android:text="@string/button12" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button12" /> 

     <Button 
      android:text="button13" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button13" /> 

     <Button 
      android:text="button14" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button14" /> 

     <Button 
      android:text="button15" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button15" /> 

     <Button 
      android:text="button16" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button16" /> 

     <Button 
      android:text="button17" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button17" /> 

     <Button 
      android:text="button18" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/button6" /> 
    </LinearLayout> 
    </ScrollView> 
</android.support.design.widget.CoordinatorLayout> 

답변

0

저도 같은 문제에 직면하고있어하지만 난 ListView에 작동하지 스크롤보기로하지만 여전히 내 대답은 당신을 도울 수있는 희망 해요!

레이아웃에서 FrameLayout을 부모로 설정하고 버튼을 LinearLayout에두고 layout_height = "300dp"로 설정하십시오. 마지막으로 코드 숨김 파일에서 setPeekHeight를 제거하십시오.

BottomSheetLayout.xml

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 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"> 

    <ScrollView 
     android:layout_height="match_parent" 
     android:layout_width="match_parent"> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="300dp"> 

        <Button 
         android:text="button1" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button1" /> 

        <Button 
         android:text="button2" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button2" /> 

        <Button 
         android:text="button3" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button3" /> 

        <Button 
         android:text="button4" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button4" /> 

        <Button 
         android:text="button5" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button5" /> 

        <Button 
         android:text="button6" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button18" /> 

        <Button 
         android:text="button7" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button7" /> 

        <Button 
         android:text="button8" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button8" /> 

        <Button 
         android:text="button9" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button9" /> 

        <Button 
         android:text="button10" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button10" /> 

        <Button 
         android:text="button11" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button11" /> 

        <Button 
         android:text="button12" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button12" /> 

        <Button 
         android:text="button13" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button13" /> 

        <Button 
         android:text="button14" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button14" /> 

        <Button 
         android:text="button15" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button15" /> 

        <Button 
         android:text="button16" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button16" /> 

        <Button 
         android:text="button17" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button17" /> 

        <Button 
         android:text="button18" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/button6" /> 
      </LinearLayout> 
    </ScrollView> 
</FrameLayout> 
1

내가 같은 문제가 없었다 및 android.support.v4.widget.NestedScrollView를 사용하여 고정. 아래쪽 시트 레이아웃에 대한 내 코드는 다음과 같습니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:paddingBottom="8dp" 
    android:paddingTop="8dp"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:clickable="true" 
     android:foreground="?attr/selectableItemBackground" 
     android:orientation="horizontal" 
     android:paddingBottom="8dp" 
     android:paddingLeft="@dimen/activity_margin" 
     android:paddingRight="@dimen/activity_margin" 
     android:paddingTop="8dp"> 

     <ImageView 
      android:layout_width="24dp" 
      android:layout_height="24dp" 
      android:layout_marginRight="32dp" 
      android:src="@drawable/ic_email_black_24dp" 
      android:tint="#737373" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:text="Email a Copy" 
      android:textColor="#737373" 
      android:textSize="16sp" /> 

    </LinearLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <WebView 
      android:id="@+id/webpage" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/colorPrimary"></WebView> 
    </android.support.v4.widget.NestedScrollView> 
</LinearLayout>