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);
...