2016-12-11 15 views
-1

scrolling activityAndroidの断片とスクロールバー

私は断片(下のバー)でこの活動をしようとしました。

error page

が、それは次のように出てきます。 style.xml(Light.NoActionBar)内のアクションバーを削除しましたが、スペースはそのままです。

は、ここでは、コード

activity_main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/fragmentContainer" 
android:layout_width="match_parent" 
android:padding="16dp" 
android:layout_height="match_parent"> 

SearchFragment.java

@Nullable 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.activity_search, container, false); 

    //Toolbar 
    final Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); 
    AppCompatActivity activity = (AppCompatActivity) getActivity(); 

    activity.setSupportActionBar(toolbar); 
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

    CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) view.findViewById(R.id.collapse_toolbar); 
    collapsingToolbarLayout.setTitle("scrolling bar"); 

    return view; 
} 

MainActivity.java

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    //Bottom Tool Bar 
    bottomBar = BottomBar.attach(this, savedInstanceState); 

    bottomBar.setFragmentItems(getSupportFragmentManager(), R.id.fragmentContainer, 
      new BottomBarFragment(SearchFragment.newInstance("Content for search."), R.drawable.ic_update_white_24dp, "검색"), 
      new BottomBarFragment(SampleFragment.newInstance("Content for favorites."), R.drawable.ic_favorite_white_24dp, "관심 리스트"), 
      new BottomBarFragment(SampleFragment.newInstance("Content for food."), R.drawable.ic_local_dining_white_24dp, "메시지"), 
      new BottomBarFragment(SampleFragment.newInstance("Content for locations."), R.drawable.ic_location_on_white_24dp, "프로필") 
    ); 

    // Setting colors for different tabs when there's more than three of them. 
    bottomBar.mapColorForTab(0, "#3B494C"); 
    bottomBar.mapColorForTab(1, "#00796B"); 
    bottomBar.mapColorForTab(2, "#7B1FA2"); 
    bottomBar.mapColorForTab(3, "#FF5252"); 

    bottomBar.setOnItemSelectedListener(new OnTabSelectedListener() { 
     @Override 
     public void onItemSelected(int position) { 
      switch (position) { 
       case 0: 
        // Item 1 Selected 
      } 
     } 
    }); 
です

発現させるactivity_search.xml

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

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

     <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:paddingTop="10dp"> 

    <android.support.v7.widget.CardView 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:textSize="20sp" 
       android:text="test2"/> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

     <android.support.v7.widget.CardView 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="10dp" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:textSize="20sp" 
        android:text="test1"/> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 


    </LinearLayout> 


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

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

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 
      app:layout_collapseMode="pin" /> 

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

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

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

答えて

0

ゴー - > MainActivityエントリに次の属性を追加 -

android:theme ="AppCompat.NoActionBar"