有人知道从Android 5.0中删除狭窄功能时拆分操作栏吗?看来它对布局不再有任何影响。Android 5.0(棒棒糖)上的拆分操作栏
7
A
回答
9
由于这个问题并没有真正回答过了......
如果拆分操作栏窄时功能从Android的5.0去除有谁知道?
是的,it was,虽然that change is not documented以外的问题跟踪器条目本身。
3
就像说你不能拆分操作栏,尽管你可以通过工具栏获得更好的结果。
Toolbar toolbarBottom = (Toolbar) findViewById(R.id.toolbar_bottom);
toolbarBottom.inflateMenu(R.menu.menu_bottom);
toolbarBottom.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
//your code
return false;
}
});
可以说,此功能与程序兼容性支持
compile "com.android.support:appcompat-v7:21.0.+"
您还需要申报工具栏在布局向后兼容是非常重要的。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"/>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"
android:layout_above="@id/toolbar"
android:layout_below="@id/toolbar_bottom" />
</LinearLayout>
0
像其他的答案,你可以从编码创建菜单的XML文件你自己吧,或者直接。
工具栏不会始终设置两个或多个项目,但您可以强制工具栏显示动作按钮始终可见,并且溢出动作将自动创建选项菜单。
其他基本自定义可以通过xml文件完成。
代码:
final Toolbar lowerTool=(Toolbar)findViewById(R.id.lower_toolbar);
lowerTool.inflateMenu(R.menu.lower_toolbar_menu);
lowerTool.getMenu().findItem(com.tvf.emag.R.id.action_previous).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT| MenuItem.SHOW_AS_ACTION_IF_ROOM);
lowerTool.getMenu().findItem(com.tvf.emag.R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);
lowerTool.getMenu().add(Menu.NONE, com.tvf.emag.R.id.action_next, Menu.NONE,
(mPager.getCurrentItem() == mPagerAdapter.getCount() - 1)
? com.tvf.emag.R.string.action_finish
: com.tvf.emag.R.string.action_next);
lowerTool.getMenu().findItem(com.tvf.emag.R.id.action_next).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT| MenuItem.SHOW_AS_ACTION_IF_ROOM);
lowerTool.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case com.tvf.emag.R.id.action_previous:
mPager.setCurrentItem(mPager.getCurrentItem() - 1);
return true;
case com.tvf.emag.R.id.action_next:
mPager.setCurrentItem(mPager.getCurrentItem() + 1);
return true;
}
return true;
}
});
相关问题
- 1. Android 5.0(棒棒糖)上的菜单图标工具栏
- 2. Android棒棒糖5.0上的工具栏阴影问题
- 3. 使用android棒棒糖工具栏快速返回操作栏
- 4. Android 5.0棒棒糖UsbDevice丢失接口
- 5. 的棒棒糖
- 6. Android Studio gradle build for Android兼容Android - 5.0棒棒糖等
- 7. Android的 - 在使用上的棒棒糖
- 8. 如何设置棒棒糖5.0上的WebView代理
- 9. android-Lollipop上的棒棒糖功能
- 10. 使用我的棒棒糖主题(在棒棒糖上)!
- 11. 在Android棒棒糖CardView
- 12. 减少BLE startScan检测到的是Android 5.0棒棒糖
- 13. Android 5.0中的蓝牙连接问题(棒棒糖)
- 14. android棒棒糖。通知不起作用
- 15. 在android棒棒糖上创建闹钟
- 16. SwitchCompat上棒棒糖设备
- 17. HAXM和棒棒糖
- 18. HttpClient失败,握手在Android 5.0中失败棒棒糖
- 19. Android的5棒棒糖SQLite的性能
- 20. 分隔线不在棒棒糖
- 21. Android上的image.setAlpha棒棒糖不起作用
- 22. “libaacdecoder.so”在棒棒糖上找不到aacdecoder
- 23. FloatingActionButton + VectorDrawable在前棒棒糖上崩溃
- 24. 状态栏中的Android 5(棒棒糖)中的显示徽标
- 25. 的cardview evalation不棒棒糖
- 26. 用于棒棒糖设备的android工具栏
- 27. 谷歌地图折线不工作在Android版本5.0(棒棒糖)
- 28. 每个棒棒糖的ToggleButton
- 29. 工具栏ActionMode背景前棒棒糖不起作用
- 30. 棒棒糖上的导航抽屉显示在系统栏后
您提供一个底部和顶部的工具栏现在,而不是系统 – tyczj 2014-10-30 18:24:21
我们如何向后兼容性做到这一点?当taget SDK是21并且appcompat库也在21级时,系统拆分actionBar,但是我看到所有的操作项都塞满了顶部,底部有一个空白色条。 – iTapAndroid 2014-11-10 23:01:40
据我所见,你需要实现一个你放在底部的工具栏。不应该是一个大问题。由于时间太少,我还无法弄清楚什么是均匀分布在操作栏上的图标。 – Florian 2014-11-11 17:21:48