>我正在使用小吃店和FAB在我的应用程序同页,每当小吃店显示浮动动作按钮不上升.
>我正在使用第三方库为attachToListView工作正常
import com.melnykov.fab.FloatingActionButton;
如果我使用默认库“无法解析attachToListView”
import android.support.design.widget.FloatingActionButton;
我的需要
> attachToListView应该工作(当Listview Scroling Down FAB将消失时).
>每当Snackbar显示浮动动作按钮应该上升
帮助我如何解决这个问题.
编辑:1
我删除了第三方库添加了默认导入(导入android.support.design.widget.FloatingActionButton),FAB是上升,但Attachtolistivew未解决.
编辑:2
我用过的Listview在我的活动中,与FAB和Snackbar.
所以我需要两个选项像FAB当Snackbar打开时,当Listview向下滚动时应该隐藏FAB.
我的SnackBar代码:
Snackbar snack = Snackbar.make(fab1, " Successfully ...!",Snackbar.LENGTH_SHORT);
View snackbarView = snack.getView();
snackbarView.setBackgroundColor(Color.parseColor("#f44336"));
snack.show();
Main.java
import com.melnykov.fab.FloatingActionButton;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.fabview);
fab1 = (FloatingActionButton) findViewById(R.id.fab);
fab1.setShadow(true);
//fab.attachToListView(provider_service_list);
//FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab1.attachToListView(listViewData, new ScrollDirectionListener()
{
@Override
public void onScrollDown() {
Log.d("ListViewFragment", "onScrollDown()");
}
@Override
public void onScrollUp() {
Log.d("ListViewFragment", "onScrollUp()");
}
}, new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
Log.d("ListViewFragment", "onScrollStateChanged()");
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
Log.d("ListViewFragment", "onScroll()");
}
});
}
fabview.xml
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app78="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinatorlayout">
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add_white_24dp"
app78:fab_colorNormal="@color/accent"
app78:fab_colorPressed="@color/accent_pressed"
app78:fab_colorRipple="@color/ripple"
app78:fabSize="normal"
app78:borderWidth="0dp"
android:layout_marginBottom="@dimen/fab_margin_bottom"
android:layout_marginRight="@dimen/fab_margin_right"
/>