0
に隠す必要がありますが、私はツールバー+ FrameLyout(フラグメント)をしたいスクロールフラグメントのツールバーは、Android
インサイドでframeLayout(TabLayout +ビューポケットベル)
私が試してみましたどのようなコードを追加しています。私が試したもの以下のコードを参照するか、このシナリオのために
<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/coordinatorLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- AppBar Layout -->
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Container" >
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
activity_main.xml
MainActivity.java
public class MainActivity extends AppCompatActivity {
private DrawerLayout mDrawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FragmentManager fragmentManager = getSupportFragmentManager();
BlankFragment mSlidingTabsHomeFragment = new BlankFragment();
fragmentManager.beginTransaction()
.replace(R.id.Container, mSlidingTabsHomeFragment)
.commit();
}
}
をいくつかの代替のアイデアを教えてくださいBlankFragment.java
あなたはviewpager.onPageChangeListenerを呼び出し、そのonPageScrolled method.belowであなたのツールバーを非表示にすることができます0fragment_blank.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
それが必要なあなたが持っているためでありますフラグメント内にframelayoutとshow viewpager?私は既存のコードをリファクタリングする必要があるので、 –
アクティビティのメインレイアウトにビューページを置くことができません – Deva
ビューページでページを変更するか、またはフラグメントを垂直にスクロールするときにツールバーを非表示にする必要がありますか? –