私のレイアウトは次のとおりです。
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:ads="http://schemas.android.com/tools"
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"
android:background="@android:color/transparent"
tools:context=".MainActivity">
<!--Content of Main-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/menu_background"
android:orientation="vertical"
>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
>
<!-- Frame where is Grid View -->
<FrameLayout
android:id="@+id/sample_content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@color/menu_background"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:nestedScrollingEnabled="true">
</FrameLayout>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/l_edds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<!--End of Content of Main -->
<!--DrawerView-->
<LinearLayout
android:id="@+id/left_RelativeLayout"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/default_color"
android:orientation="vertical">
<EditText
android:id="@+id/left_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:layout_marginTop="15dip"
android:background="@drawable/edit_field"
android:drawableRight="@drawable/ic_search"
android:hint="@string/text_search"
android:imeOptions="actionSearch"
android:inputType="textNoSuggestions"
android:lines="1"
android:padding="5dip"
android:textColor="@color/action_bar_color"
android:textColorHint="@color/edit_search_hint_color"
android:textSize="14sp"/>
<ListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/editText"
android:background="@color/default_color"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/selector_bg_key"/>
</LinearLayout>
<!--End of DrawerView-->
</android.support.v4.widget.DrawerLayout>
私の活動は:
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity
{
protected void onCreate(Bundle savedInstanceState) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
fragment = SlidingTabsColorsFragment.newInstance();
transaction.replace(R.id.sample_content_fragment, fragment, FRAGMENT_TAG);
transaction.commit();
...
}
Android 5 で、SlidingTabsColorsFragment で gridView をスクロールすると、ツールバーが MainActivity で非表示になります