如何在 android 中获得浮动操作按钮的图像类型视图下方?
How can i get below image type view of Floating Action Button in android?
我知道如何设置浮动操作按钮,如下图所示。但是我需要在点击时或任何时候想要显示该布局时显示不同的布局。附上第二个布局
我怎样才能做到这一点?
参考这个 link 浮动操作按钮工具栏 https://github.com/AlexKolpa/fab-toolbar
这里需要在项目中添加依赖
compile 'com.github.alexkolpa:floating-action-button-toolbar:0.5.1'
在您的 XML 文件中,
<com.github.alexkolpa.fabtoolbar.FabToolbar
android:id="@+id/fab_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tb:tb_anim_duration="500"
tb:tb_button_gravity="end"
tb:tb_container_gravity="center"
>
<ImageView
android:id="@+id/attach"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_attachment_white_48dp"
android:layout_marginLeft="@dimen/icon_margin"
android:layout_marginRight="@dimen/icon_margin"
/>
<!-- More buttons can be added here -->
要隐藏或显示工具栏,只需调用 hide()
和 show()
。
FabToolbar fabToolbar = ((FabToolbar) findViewById(R.id.fab_toolbar));
findViewById(R.id.attach).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
fabToolbar.hide();
}
});
我知道如何设置浮动操作按钮,如下图所示。但是我需要在点击时或任何时候想要显示该布局时显示不同的布局。附上第二个布局
我怎样才能做到这一点?
参考这个 link 浮动操作按钮工具栏 https://github.com/AlexKolpa/fab-toolbar
这里需要在项目中添加依赖
compile 'com.github.alexkolpa:floating-action-button-toolbar:0.5.1'
在您的 XML 文件中,
<com.github.alexkolpa.fabtoolbar.FabToolbar
android:id="@+id/fab_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tb:tb_anim_duration="500"
tb:tb_button_gravity="end"
tb:tb_container_gravity="center"
>
<ImageView
android:id="@+id/attach"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_attachment_white_48dp"
android:layout_marginLeft="@dimen/icon_margin"
android:layout_marginRight="@dimen/icon_margin"
/>
<!-- More buttons can be added here -->
要隐藏或显示工具栏,只需调用 hide()
和 show()
。
FabToolbar fabToolbar = ((FabToolbar) findViewById(R.id.fab_toolbar));
findViewById(R.id.attach).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
fabToolbar.hide();
}
});