升级到 Wear 2.0.0 版本后 Wearable Action Drawer 坏了
Wearable Action Drawer broke after upgrading to the release of Wear 2.0.0
我有一个 acton 抽屉,有 3 个项目,从菜单 xml 文件中提取。
<android.support.wearable.view.drawer.WearableActionDrawer
android:id="@+id/bottom_action_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:action_menu="@menu/action_drawer_menu"
android:background="@color/menu_background"/>
菜单文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_calibrate"
android:icon="@drawable/ic_balls"
android:title="@string/calibrate_shots"/>
<item android:id="@+id/menu_play"
android:icon="@drawable/ic_tennis"
android:title="@string/play_session" />
<item android:id="@+id/menu_sync"
android:icon="@drawable/ic_synchronize"
android:title="@string/sync_sessions" />
</menu>
当使用 com.google.android.support:wearable:2.0.0-alpha3 编译时,一切正常,当我在菜单的 "peek" 边缘上切换时,菜单打开正常。当使用 com.google.android.support:wearable:2.0.0 时,点击 "peek" 边缘只会运行菜单中第一项的 onclick 事件。 Java onclick 代码:
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if(menuItem.getTitle().toString().equals(getResources().getString(R.string.play_session))) {
startStartPlayActivity();
} else if(menuItem.getTitle().toString().equals(getResources().getString(R.string.calibrate_shots))) {
startStartCalibrationActivity();
} else if(menuItem.getTitle().toString().equals(getResources().getString(R.string.sync_sessions))) {
startSyncActiviy();
}
mContainerView.peekDrawer(Gravity.BOTTOM);
return false;
}
如果这是发行版的错误或我做错了什么,有什么想法吗?我正在测试 LG Urbane 第二代 LTE。
根据 Peeking Drawers documentation:
By default, the action drawer shows the first action with a chevron symbol when there is more than one action.
因此点击偷看抽屉应该会触发第一个动作。它继续说:
If you prefer to display just the overflow icon (3 vertical dots) without the first action, you can override the default behavior by setting the show_overflow_in_peek flag
to true
.
<android.support.wearable.view.drawer.WearableActionDrawer
android:id="@+id/bottom_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
app:show_overflow_in_peek="true"/>
我有一个 acton 抽屉,有 3 个项目,从菜单 xml 文件中提取。
<android.support.wearable.view.drawer.WearableActionDrawer
android:id="@+id/bottom_action_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:action_menu="@menu/action_drawer_menu"
android:background="@color/menu_background"/>
菜单文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_calibrate"
android:icon="@drawable/ic_balls"
android:title="@string/calibrate_shots"/>
<item android:id="@+id/menu_play"
android:icon="@drawable/ic_tennis"
android:title="@string/play_session" />
<item android:id="@+id/menu_sync"
android:icon="@drawable/ic_synchronize"
android:title="@string/sync_sessions" />
</menu>
当使用 com.google.android.support:wearable:2.0.0-alpha3 编译时,一切正常,当我在菜单的 "peek" 边缘上切换时,菜单打开正常。当使用 com.google.android.support:wearable:2.0.0 时,点击 "peek" 边缘只会运行菜单中第一项的 onclick 事件。 Java onclick 代码:
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if(menuItem.getTitle().toString().equals(getResources().getString(R.string.play_session))) {
startStartPlayActivity();
} else if(menuItem.getTitle().toString().equals(getResources().getString(R.string.calibrate_shots))) {
startStartCalibrationActivity();
} else if(menuItem.getTitle().toString().equals(getResources().getString(R.string.sync_sessions))) {
startSyncActiviy();
}
mContainerView.peekDrawer(Gravity.BOTTOM);
return false;
}
如果这是发行版的错误或我做错了什么,有什么想法吗?我正在测试 LG Urbane 第二代 LTE。
根据 Peeking Drawers documentation:
By default, the action drawer shows the first action with a chevron symbol when there is more than one action.
因此点击偷看抽屉应该会触发第一个动作。它继续说:
If you prefer to display just the overflow icon (3 vertical dots) without the first action, you can override the default behavior by setting the
show_overflow_in_peek flag
totrue
.
<android.support.wearable.view.drawer.WearableActionDrawer
android:id="@+id/bottom_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
app:show_overflow_in_peek="true"/>