小编Kus*_*arg的帖子

无法滚动AppBarLayout并平滑地折叠工具栏和NestedScrollView

我正在使用我正在使用的一个Android应用程序CoordinatorLayout,AppBarLayoutCollapsingToolbarLayout使用折叠工具栏功能.

NestedScrollView在布局中使用AppBarLayout以相同的布局展开和折叠.当我试图从屏幕中心向上滚动然后它不起作用但是当我尝试从屏幕右上角向上滚动屏幕时它会顺利滚动.

下面提到的是我的xml文件

layout.xml

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    android:paddingBottom="2dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp"
    android:layout_gravity="fill_vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/fragment_back_color"
            android:orientation="vertical">


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="5dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:background="@drawable/new_recharge" />

                <com.spiceladdoo.views.RobotTextviewRegular
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:text="NEW PAYMENT"
                    android:textColor="@color/offer_name_text_color" />

            </LinearLayout>


            <RelativeLayout

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:background="@color/white"
                android:paddingBottom="20dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="20dp">

                <HorizontalScrollView
                    android:id="@+id/hsv"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:fillViewport="true"
                    android:measureAllChildren="false"
                    android:scrollbars="none">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:orientation="horizontal">

                        <LinearLayout …
Run Code Online (Sandbox Code Playgroud)

android android-collapsingtoolbarlayout nestedscrollview

24
推荐指数
3
解决办法
2万
查看次数

如何在向下滚动时扩展AppBarLayout到达RecyclerView的顶部

我正在使用我正在使用的一个Android应用程序CoordinatorLayout,AppBarLayoutCollapsingToolbarLayout使用高级折叠栏功能.

我正在使用recyclerview来显示片段中的项目数.当我向上滚动recyclelerview时,它会平滑地折叠AppBarLayout,但当我向下滚动并到达第一项时,recyclerview它会自动停止滚动而不会扩展`AppBarLayout'.

然后我再次向下滚动以使其AppBarLayout可见.所以我的要求是当我到达recyclerview的顶部时向下滚动它必须扩展`AppBarLayout'.

我们应该怎么做.任何的想法 ?请查看相同https://www.dropbox.com/s/va5jk27ikytk​​5ax/app_collapsebar_issue.mp4?dl=0的视频

这是我的布局: -

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:fitsSystemWindows="true">

    <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        >

        <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:background="@drawable/offer_image"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <!--    <com.flaviofaria.kenburnsview.KenBurnsView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="220dp"
            android:src="@drawable/offer_image" />-->
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">


            <com.flaviofaria.kenburnsview.KenBurnsView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="220dp"

            android:src="@drawable/offer_image" />

            <FrameLayout
            android:id="@+id/collapse_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#B3c85a00">

            </FrameLayout> …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout

18
推荐指数
1
解决办法
5532
查看次数

子片段自动销毁

我有一个父片段,即在其上FragmentA膨胀一个子片段FragmentB.在onCreateView函数中FragmentB尝试膨胀另一个片段`FragmentC'.

FragmentA.java

public class FragmentA extends Fragment {

    private static final String TAG = "FragmentA";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                 Bundle savedInstanceState) {
    /* Inflate the layout for this fragment */
    View view = inflater.inflate(R.layout.root_fragment, container, false);


    FragmentManager manager = getChildFragmentManager();

    FragmentTransaction transaction = manager
        .beginTransaction();
    /*
     * When this container fragment is created, we fill it with our first
         * "real" fragment
         */
    transaction.replace(R.id.container_main, new FragmentRecharge());
    transaction.addToBackStack(null);
    transaction.commit();


    return view;
    } …
Run Code Online (Sandbox Code Playgroud)

android fragment android-fragments android-nested-fragment

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