如何最好地实现 android 中的持久性工具栏?
How is a persistent toolbar in android best implemented?
在 Google 音乐应用程序中,播放歌曲时,屏幕底部会出现一个工具栏,其中包含媒体信息和控件。我想要同样的功能。
目前,我正在使用工具栏。
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
android:id="@+id/tbMedia"
android:layout_alignParentBottom="true">
</android.support.v7.widget.Toolbar>
播放音频时显示。但是,我正在做的事情感觉很老套。
使用工具栏是最好的方法吗?
使用工具栏控制媒体没有任何问题。这就是操作栏的用途,工具栏只是实现操作栏的最新方式。如果您想要屏幕底部的栏,请考虑使用拆分操作栏。
以下是来自 ActionBar 开发指南的相关信息:
To enable split action bar when using the support library, you must do two things:
- Add uiOptions="splitActionBarWhenNarrow" to each element or to the element. This attribute is understood only by API level 14 and higher (it is ignored by older versions).
- To support older versions, add a element as a child of each element that declares the same value for "android.support.UI_OPTIONS".
For example:
<manifest ...>
<activity uiOptions="splitActionBarWhenNarrow" ... >
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>
</manifest>
在 Google 音乐应用程序中,播放歌曲时,屏幕底部会出现一个工具栏,其中包含媒体信息和控件。我想要同样的功能。
目前,我正在使用工具栏。
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
android:id="@+id/tbMedia"
android:layout_alignParentBottom="true">
</android.support.v7.widget.Toolbar>
播放音频时显示。但是,我正在做的事情感觉很老套。 使用工具栏是最好的方法吗?
使用工具栏控制媒体没有任何问题。这就是操作栏的用途,工具栏只是实现操作栏的最新方式。如果您想要屏幕底部的栏,请考虑使用拆分操作栏。
以下是来自 ActionBar 开发指南的相关信息:
To enable split action bar when using the support library, you must do two things:
- Add uiOptions="splitActionBarWhenNarrow" to each element or to the element. This attribute is understood only by API level 14 and higher (it is ignored by older versions).
- To support older versions, add a element as a child of each element that declares the same value for "android.support.UI_OPTIONS".
For example:
<manifest ...> <activity uiOptions="splitActionBarWhenNarrow" ... > <meta-data android:name="android.support.UI_OPTIONS" android:value="splitActionBarWhenNarrow" /> </activity> </manifest>