- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 roughike 的 BottomBar 2.0:https://github.com/roughike/BottomBar/
当我显示 SnackBar 时,它会显示在 BottomBar 本身上。
我希望它绘制在 BottomBar 之上。
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/here"
android:background="#fff">
<FrameLayout
android:id="@+id/contentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomBar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Three Buttons Bar"
android:id="@+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textColor="@color/colorPrimary"
android:textSize="35sp" />
</FrameLayout>
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
MainActivity.java:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(int tabId) {
switch (tabId) {
case R.id.recent_item:
Snackbar.make(findViewById(R.id.main_activity), "Recent Item Selected", Snackbar.LENGTH_LONG).show();
break;
case R.id.favorite_item:
Snackbar.make(findViewById(R.id.main_activity), "Favorite Item Selected", Snackbar.LENGTH_LONG).show();
break;
case R.id.location_item:
Snackbar.make(findViewById(R.id.main_activity), "Location Item Selected", Snackbar.LENGTH_LONG).show();
break;
}
}
});
}
}
截图:
布局文件有问题吗??
我错过了什么??
我还检查了这个:Move snackbar above the bottom bar , 但它没有帮助..
编辑:
我试过了 as Abtin said :
Snackbar.make(bottomBar, "Location Item Selected", Snackbar.LENGTH_LONG).show();
和
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs"
app:bb_behavior="underNavbar"/>
现在变成了这样:
如您所见,当我设置 app:bb_behavior="underNavbar"
时,BottomBar 下方有这个未使用的空间,这不是我想要的..
最佳答案
有了新的 Material 设计,Snackbars 有了新的外观..你可以用这行代码在 BottomBar 上方显示 snackbar:
Snackbar snackbar = Snackbar.make(parentView, text, duration);
snackbar.setAnchorView(bottomBar);
这将完成工作。
关于android - 如何在 Bottombar 上方显示 Snackbar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40092618/
Snackbar.make(...).show() 将只显示最后一个 snackbar,不像 toast 其他 snackbar 都消失了。 for(int i = 1;i mSnackbarLis
Snackbar.make(...).show() 将只显示最后一个 snackbar,不像 toast 其他 snackbar 都消失了。 for(int i = 1;i mSnackbarLis
我有一个实现 swipetorefresh 布局的 recyclerview - 如果您在列表中向下滑动手指,它将加载较新的帖子。它还有一个 onloadmorelistener 用于对我的 recy
我正在尝试添加 Snackbar到我的应用程序, Snackbar.make(findViewById(android.R.id.content), R.string.not_
我对 snackbar 有疑问。我的 snackbar 对解雇没有反应 我的代码: ConnectivityReceiver = new BroadcastReceiver() { @
我试图在显示 snackbar 时将焦点直接放在 snackbar 中的操作按钮上,以便让用户知道可以使用 snackbar 中显示的警报消息执行某些操作。注意:这是针对对讲模式。我尝试使用 requ
如果我连续多次调用snackbar,则只显示最后一个snackbar 项。 例如使用下面的代码,只会显示第 3 项。似乎第 1 项和第 2 项的 Snackbar.LENGTH_LONG 被忽略(并设
我的应用程序中有一个包含消息的 RecyclerView。在向右滑动时,我将其配置为删除消息,在向左滑动时,我将其配置为存档消息。下面是 ItemTouchHelper 部分删除归档相关的代码: if
我正在尝试使用此设置 snackbar 长度: Snackbar oSnackbar = Snackbar.make(Context, "Testing", Snackbar.LENGTH_LONG)
flutter SnackBar的动画入口是什么? ScaffoldMessanger.of(context).showSnackBar(SnackBar( animation: /* --- *
在我的应用程序中,可能(并且有意!)多个 SnackBar元素被创建。这些 SnackBar元素排队并一个接一个地显示,这一切都很好。但是,如果我转到不同的屏幕然后返回(所以 push 和 pop 一
我有一个 flutter 应用程序,它在应用程序的不同屏幕上发出许多不同的 http 请求。现在,我想实现一些通用的错误处理,例如,每当没有连接时,我都想显示一个 SnackBar,无论我目前在应用程
我因为工作室提示 Dialog 而苦苦挣扎已弃用, 所以我又去阅读文档,似乎 Toast也被弃用了。 所以我尝试从 Toast 迁移至Snackbar ,但目前失败...我 我加了 implement
我有问题在我的应用程序中实现了 BLoC 模式。 一旦我有一个特殊的事件,我需要显示一个 snackbar ,但我有这个错误: The following assertion was thrown b
我尝试在 JavaScript 中使用“if else”语句,但无法使其工作。 这是js脚本: var vid = document.getElementById("myVideo"); functi
我使用 Material 2 创建了 Snackbar(下面我添加了演示)。我在主页中有一个按钮,当我单击该按钮时,它会在页面底部显示消息(snackbar)。我想将其(快捷栏消息)更改为页面的右上角
我有按钮而不是 float 操作按钮,我想将其与 snackbar 锚定,因为它与 float 操作栏锚定,就像显示 snackbar 时 float 操作按钮向上移动一样,对于 float 操作栏,
在ReactJS中,我想仅在登录成功时显示material-ui Snackbar。在ReactJS中有哪些方法可以做到这一点? 最佳答案 Material-ui Snackbar 的 open 状态
您好,我有一段代码可以生成 snackbar 。我使用带有关闭选项的 Bootstrap 警报来生成 snackbar ,但是当我单击关闭按钮时,它对我不起作用。是否可以添加关闭选项?如果是,你能解释
令我惊讶的是,如果 TextView 跨越多行,Snackbar 本身似乎会在 TextView 上设置额外的填充。它有效地使 Snackbar 的高度加倍,并且由于某种原因仅影响垂直填充。我在 Sn
我是一名优秀的程序员,十分优秀!