小编ozz*_*zem的帖子

活动中的浮动操作按钮 - 如何锚定到片段中的recyclerview?

我在这个问题中遇到了同样的问题 浮动操作按钮没有完全显示在片段内

我的activity_main中有一个tablayout和两个标签(包含不同的片段,其中一个包含recyclerView).当我将FAB放入片段时,在我向下滚动recyclerView之前,FAB没有完全显示.

因此,我按照链接问题中的建议将我的FAB移动到coordinator_layout小部件的activity_main.xml文件中,并且它运行良好.

通过这种方式,我在活动中有一个FAB,而不是在片段中,我想知道如何将我的工厂锚定到片段中的recyclerview,例如让它在回收器卷轴中设置动画?

现在带有tablayout的activity_main.xml:

activity_main.xml中

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbarlayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true" >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar1"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            android:background="?attr/colorPrimary" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar1"
            android:background="?attr/colorPrimary"
            android:scrollbars="horizontal"
            app:tabMode="scrollable" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_gravity="bottom|right"
        android:layout_marginBottom="20dp"
        android:layout_marginRight="20dp"
        android:src="@drawable/ic_action_location_found"
        app:fabSize="normal" />
    </android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

fragment.xml之

<RelativeLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/activity_vertical_margin" >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/start_button"
        android:scrollbars="vertical" />


</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-viewpager floating-action-button android-recyclerview

10
推荐指数
1
解决办法
1万
查看次数

用于android的ListView过滤器

我有一个适配器,我使用一个 ad.getFilter().filter(s);过滤器listView.
如果我在EditText中写一个单词,它的效果很好.
如果在单词后写一个空格字符,它不起作用(结果没有行).
我想用名称和surmane做一个过滤器.我想插入"Mario Rossi"edittext并得到一个结果..我希望我解释.
非常感谢.

private TextWatcher filterTextWatcher = new TextWatcher() {

    public void afterTextChanged(Editable s) {
    }

    public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
    }

    public void onTextChanged(CharSequence s, int start, int before,
                int count) {
        ad.getFilter().filter(s);               
    }

};
Run Code Online (Sandbox Code Playgroud)

android listview filter adapter

6
推荐指数
1
解决办法
671
查看次数