0
我有个同伴配置的应用为我的表盘,它只是呈现的各种设置的片段(每个设置,您就可以通过他们迅速刷卡)下方ViewPager片段滑动系统列
我想片段视图在维护动作栏时可以滚动,但是发生的情况是,如果您在动作栏上向上滑动,它会在系统栏下消失,并且很难向后移动。
这是我的各种布局和代码组件;让我知道如果有更多我需要:
AndroidManifest/xml
<?xml version="1.0" encoding="utf-8"?>
<uses-feature android:name="android.hardware.type.watch" android:required="false"/>
<!-- Required to act as a custom watch face. -->
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<!-- So we can keep the screen on and start vibrations -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ref_watch_icon"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".RefWatch"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name=
"com.pipperpublishing.RefWatch.wearable.watchface.CONFIG_DIGITAL" />
<category android:name=
"com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
我的活动的布局XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
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.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_media_rew" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_media_ff" />
和我的大多数OnCreate中的:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ref_watch);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
...
/*-------------------------------------------------------------*/
/* Set up Settings Pager, Adapter, and floating action buttons */
/*-------------------------------------------------------------*/
...
// Create the adapter that will return a fragment for each of the menu setting sections
mSettingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
...
mSettingsViewPager = (ViewPager) findViewById(R.id.container);
...
// Set up the ViewPager with the Settings adapter.
mSettingsViewPager.setAdapter(mSettingsPagerAdapter);
...