2016-09-15 5 views
3

내 앱에서 NestedScrollView를 열고 있는데, 화면의 맨 아래에서 열립니다. 상단에서 어떻게 열 수 있습니까?상단에서 bottomSheet를 여는 방법?

app:layout_behavior="android.support.design.widget.BottomSheetBehavior" 

그러나 다음과 같은 오류와 응용 프로그램의 충돌 :

The view is not associated with BottomSheetBehavior 

화면의 상단에서 하단 시트를 열 수있는 방법이 있나요

나는 다음 줄을 제거하려고? 나는 그것이 디자인이 바닥에서 표시하기위한 것입니다 때문에, 구글의 디자인 라이브러리를 사용하는 것은 불가능하다 생각

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="apps.radwin.wintouch.activities.alignmentActivities.WorkordersSelectionActivity" 
    tools:showIn="@layout/app_bar_workorders_selection"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="8dp" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabsLayoutWorkorderSelection" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      /> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/workorderSelectionMainViewPagerContainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:src="@drawable/add_workorders_plus" 
     android:layout_marginLeft="@dimen/fab_margin" 
     android:layout_marginRight="@dimen/fab_margin" 
     android:layout_marginBottom="@dimen/fab_margin" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" /> 


    <android.support.design.widget.CoordinatorLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <android.support.v4.widget.NestedScrollView 
      android:id="@+id/bottom_sheet" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:clipToPadding="true" 
      android:background="#293339" 
      app:layout_behavior="android.support.design.widget.BottomSheetBehavior" 
      > 

      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toStartOf="@+id/fab"> 


       ... 
       ... 
       ... 


       <View 
        android:layout_width="match_parent" 
        android:layout_height="20dp" 
        android:layout_below="@+id/workorderFilterPopup_CompleteImage" 
        ></View> 


      </RelativeLayout> 



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

    </android.support.design.widget.CoordinatorLayout> 




</RelativeLayout> 

답변

0

: 여기

ViewPager mainViewPager; 
private BottomSheetBehavior mBottomSheetBehavior; 
int switcher = 1; 
View menuPopupView; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.workorder_selection_layout_with_fragment); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

    ... 
    .... 
    ... 


    filterButton = (Button)  
    findViewById(R.id.filterButtonMainWorkorderSelection); 
    filterButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 

      if (switcher == 1) { 
       mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); 
       switcher = 2; 
      } else { 
       mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); 
       switcher = 1; 
      } 


     } 
    }); 

    /////////////////////////////////////////// 
    //////////////Buttom Sheet///////////////// 
    /////////////////////////////////////////// 

    View bottomSheet = findViewById(R.id.bottom_sheet); 

    mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); 


} 

내 XML입니다 : 여기

내 활동 .

https://material.io/guidelines/components/bottom-sheets.html
"하단 시트가 화면 하단에서 위로 이동하여 더 많은 내용을 표시합니다."

나는 bottomsheet 상단에서 표시할지 여부를 제어 할 ATTR을 추가 한

https://github.com/jernkuan/bottomsheet

Flipboard는의 bottomsheet의 수정 된 버전을 사용하여 시도.