met*_*ink 3 android menu floating material-design
我有浮动操作菜单,我使用这个库来制作它'com.github.clans:fab:1.6.1'
现在我需要在点击它时更改我的图标.我有一些图标,当我点击菜单时,我需要将其转换为另一个图标(图标加).可能吗?这是我的xml:
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/menu3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
fab:menu_icon="@drawable/ic_float_cards"
android:layout_margin="16dp"
fab:menu_animationDelayPerItem="0"
fab:menu_colorNormal="@color/event_background"
fab:menu_colorPressed="@color/fab_colorPressed"
fab:menu_colorRipple="@color/fab_colorRipple"
fab:menu_labels_maxLines="2"
fab:menu_labels_ellipsize="end">
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dial_fill"
fab:fab_label="?????????"
style="@style/MenuButtonsSmall.Green" />
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dial_pay"
fab:fab_label="????????"
style="@style/MenuButtonsSmall.Yellow" />
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dial_outcome"
fab:fab_label="?????????"
style="@style/MenuButtonsSmall.Red" />
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dial_income"
fab:fab_label="?????? ????????"
style="@style/MenuButtonsSmall.DarkPink" />
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dial_send"
fab:fab_label="?????????"
style="@style/MenuButtonsSmall.Purple" />
</com.github.clans.fab.FloatingActionMenu>
Run Code Online (Sandbox Code Playgroud)
在第一个图标是ic_float_cards,但当我点击它应该是ic_float_cross
如果你有一些想法告诉我,请)
小智 10
这样做可以恢复原始图标.
final FloatingActionMenu fab = (FloatingActionMenu) findViewById(R.id.menu3);
fab.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
@Override
public void onMenuToggle(boolean opened) {
int drawableId;
if (opened) {
drawableId = R.drawable.ic_float_cross;
} else {
drawableId = R.drawable.ic_float_cards;
}
Drawable drawable = getResources().getDrawable(drawableId);
fab.getMenuIconView().setImageDrawable(drawable);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3421 次 |
| 最近记录: |