标签: android-nestedscrollview

Jetpack compose 中的折叠工具栏

如何使用 Jetpack compose 构建 Instagram 个人资料页面。我尝试过多个库,例如NestedScrollViewCollapsingToolbar来获得可折叠/可滚动的顶栏,但它们看起来并不平滑。使用 CoordinatorLayout 通过 XML 进行构建很容易。

预期滚动:- Instagram 个人资料页面

使用 NestedScrollView 库:- NestedScrollView

android android-collapsingtoolbarlayout android-nestedscrollview android-jetpack-compose

5
推荐指数
1
解决办法
3203
查看次数

Android:animateLayoutChanges与CoordinatorLayout无法正常工作

我一直在尝试在我的Android应用程序中使用协调器布局.我有一个应用栏布局和协调器布局中的嵌套滚动视图.在我的嵌套滚动视图中,我有一个线性布局,animateLayoutChanges为true.

我的问题是,当使项目可见性为可见时,线性布局高度的高度增加时,线性布局在Appbar布局下.只有在单击屏幕或滚动后,才会出现正确的滚动效果.

我创建了一个简单的应用程序来显示问题.下面是布局.

<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    tools:context="testapp.test.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:animateLayoutChanges="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:animateLayoutChanges="true"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

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

    <android.support.v4.widget.NestedScrollView
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:animateLayoutChanges="true">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Show"
            android:id="@+id/test_Button"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hide"
            android:id="@+id/test_Button2"/>
        <TextView
            android:id="@+id/test_tv"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:visibility="gone"
            android:background="@color/colorAccent"/>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

在此单击显示按钮时,我正在显示Textview.请查看图片以了解我的问题.

图1-初始状态.

图2-这是问题所在.我点击了Show.现在,由于通过动画布局更改动画,线性布局已在App Bar Layout下移动.如您所见,"显示"按钮已在App Bar下移动.

图3-现在,当我触摸屏幕或滚动时,滚动变得正确.

请帮忙.我一直在努力解决这个问题.谢谢.

初始状态.

这是问题所在. 我点击了Show. 由于动画,现在线性布局已在App Bar Layout下移动. 现在,当我触摸屏幕或滚动时,滚动变得正确.

android android-coordinatorlayout android-nestedscrollview

4
推荐指数
1
解决办法
2604
查看次数

列表视图不使用NestedScrollView中的视图分页器在片段中滚动

嗨,我需要创建像whatsapp的布局,滚动操作栏但不滚动tabLayout.我在其中使用了viewpager for loads fragment.在片段中我添加了listview但在Listview上滚动该操作栏不在那里滚动.使用stackoverflow上的一些教程我得到了为此需要使用nestedScrollView,它适用于我.但它停止滚动listview.我用这个代码.

activity_my.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"></android.support.design.widget.CollapsingToolbarLayout>

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

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_gravity="bottom"
    app:layout_anchor="@+id/appbar"
    app:layout_anchorGravity="bottom"
    app:layout_collapseMode="none">

    <ImageView
        android:id="@+id/tabBg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/primary"
        android:scaleType="fitXY" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"
        android:background="#00000000"
        app:layout_anchor="@+id/appbar"
        app:layout_anchorGravity="bottom"
        app:layout_collapseMode="none"
        app:tabGravity="fill"
        app:tabIndicatorColor="#fff"
        app:tabIndicatorHeight="2dp"
        app:tabMode="scrollable"
        app:tabSelectedTextColor="#fff"
        app:tabTextColor="#fff" />

</FrameLayout>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?attr/actionBarSize"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="1000dp"
        android:orientation="vertical">

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

<!--<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?attr/actionBarSize"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />--> …
Run Code Online (Sandbox Code Playgroud)

android listview android-viewpager android-nestedscrollview

4
推荐指数
1
解决办法
4187
查看次数

嵌套的scrollview不占用CoordinatorLayout中的可用空间

我正面临着实施NestedScrollview内部问题的问题CoordinatorLayout.请参阅以下布局代码:

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

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:expanded="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <LinearLayout
            android:layout_marginTop="?android:attr/actionBarSize"
            app:layout_collapseMode="parallax"
            android:layout_width="match_parent"
            android:weightSum="2"
            android:orientation="horizontal"
            android:gravity="bottom"
            android:fitsSystemWindows="true"
            android:background="@color/aop_gray"
            android:layout_height="87dp">

            <LinearLayout
                android:background="#E5E5E5"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">
            </LinearLayout>

        </LinearLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_anders"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/Custom_red"
            style="@style/CustomTheme.CustomActionBar"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingTop="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_horizontal_margin"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:id="@+id/test1"
            android:layout_gravity="fill_vertical"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="match_parent">

            <com.Custom.saving.widgets.CustomTextView
                android:id="@+id/aop_data_overview_form_header"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                style="@style/AopHeader"
                android:layout_marginBottom="@dimen/default_margin"
                android:text="@string/is_your_data_correct_header" …
Run Code Online (Sandbox Code Playgroud)

android coordinator-layout android-nestedscrollview

4
推荐指数
1
解决办法
3126
查看次数

Google Map Fragment在NestedScrollView中滚动

我有一个NestedScrollView父母和片段包含googleMap其子.当我在地图中向下或向上滚动时,NesetdScrollView会滚动,我无法在地图内滚动.直到现在我已经通过创建透明图像尝试了堆栈溢出的解决方案,但它对我没有用.

XML:

  <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/car_progress"
        android:id="@+id/nested_scroll"
        android:visibility="gone"

        >
............
............
<RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/first_section"
                android:visibility="gone"
                android:id="@+id/map_wrapper"
                android:orientation="vertical"
                android:layout_marginTop="10dp"
                >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/dealer_location"
                    android:textAllCaps="true"
                    android:textColor="@color/colorPrimary"
                    style="@style/BoldStyle"
                    android:layout_marginLeft="@dimen/single_title_dimen"
                    android:layout_marginRight="@dimen/single_title_dimen"
                    android:id="@+id/dealer_head"

                    />

                <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:id="@+id/map"
                    android:name="com.google.android.gms.maps.SupportMapFragment"
                    android:layout_below="@+id/dealer_head"
                    />
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imagetrans"
                    android:layout_alignTop="@+id/map"
                    android:layout_alignBottom="@+id/map"
                    android:layout_alignEnd="@+id/map"
                    android:layout_alignRight="@+id/map"
                    android:layout_alignLeft="@+id/map"
                    android:layout_alignStart="@+id/map"
                    android:src="@android:color/transparent"/>

            </RelativeLayout>
.....
.....
 </android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

码:

transImg.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int action = event.getAction();
                switch (action) {
                    case MotionEvent.ACTION_DOWN: …
Run Code Online (Sandbox Code Playgroud)

android google-maps fragment android-nestedscrollview

4
推荐指数
1
解决办法
3256
查看次数

NedtedScrollView 中的 RecyclerView 为每个项目调用 onCreateViewHolder

我有一个案例,当我需要使用RecyclerViewinside 时NestedScrollView。问题是在 init 方法onCreateViewHolderonBindViewHolder调用列表中的每个项目(示例中为 100 个项目)期间。

所以屏幕上没有回收视图,在更复杂的情况下,我有很大的性能问题。

我的代码Activity

public class MyActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final RecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(new MyListAdapter());
}
}
Run Code Online (Sandbox Code Playgroud)

我的代码.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/refresh"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:nestedScrollingEnabled="false"/>

</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我的适配器代码:

public class MyListAdapter extends RecyclerView.Adapter<MyListAdapter.Holder>{

@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
    final …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-nestedscrollview

4
推荐指数
1
解决办法
859
查看次数

ViewPager 中的水平 RecyclerView 不滚动

我在复杂的层次结构中有一个水平 RecyclerView,看起来像这样 -

<ViewPager id="+@id/first">
    <ViewPager id="+@id/second"> this viewpager is taking away the scroll event
        <SwipeToRefreshLayout>
            <RecyclerView> //this one is vertical
                <RecyclerView id="@id/rv1"> //this one is horizontal
                <RecyclerView id="@id/rv2"> //this one is working fine (different type)
            </RecyclerView>
        </SwipeToRefreshLayout>
    </ViewPager>
</ViewPager>
Run Code Online (Sandbox Code Playgroud)

现在的问题是第二个 ViewPager 正在劫持 Horizo​​ntal RV 的滚动条。该垂直 RV 中有 2 种类型的水平 RV(RV1 和 RV2)。但只有其中一个(RV1)面临这个问题。第二个 (RV2) 工作正常。此外,当我按住然后滚动工作正常。当 RV1 已经在滚动并且尚未稳定时,滚动也可以正常工作。我已经提到了其他关于设置 NestedScrolling false 的答案。似乎没有任何工作。

android android-viewpager android-recyclerview android-nestedscrollview

4
推荐指数
3
解决办法
1610
查看次数

NestedScrollView中的CardView在底部显示额外的空间

我有一些布局问题.我将一个cardView放在NestedScrollView中,完全放在CoordinatorLayout中.并且,它在底部添加了大量填充.有人可以解释为什么会发生这种情况.我知道cardView在下面的L设备中使用额外的填充来显示圆角和阴影,但是它需要这么多的填充,而且也只需要在底部.

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.startup.practice.getplaced.activities.InfoEventDetails">
    <android.support.design.widget.AppBarLayout
        android:id="@+id/info_event_details_appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/content_image_height"
        android:theme="@style/AppTheme.AppBarOverlay"
        >
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/info_event_details_collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp">
            <ImageView
                android:src="@drawable/manhattan_college_logo"
                android:scaleType="centerCrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="parallax"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/sheet_text_scrim_height_top"
                android:background="@drawable/scrim_top"
                app:layout_collapseMode="pin"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/sheet_text_scrim_height_bottom"
                android:layout_gravity="bottom"
                android:layout_alignBottom="@+id/image"
                android:background="@drawable/scrim_bottom"/>
            <android.support.v7.widget.Toolbar
                android:id="@+id/info_event_details_appbar_toolbar"
                app:layout_collapseMode="pin"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/AppTheme.PopupOverlay"/>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView>
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <RelativeLayout
                android:layout_margin="@dimen/activity_horizontal_margin"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/info_event_details_date"
                    android:text="12th July"
                    android:layout_alignParentRight="true"
                    android:textSize="@dimen/date_text_size"
                    android:textColor="#90000000"
                    android:textStyle="bold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    />
                <TextView
                    android:id="@+id/info_event_details_title"
                    android:layout_toLeftOf="@id/info_event_details_date"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Attention! Students …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-cardview android-nestedscrollview

3
推荐指数
1
解决办法
3075
查看次数

Android espresso NestedScrollView,如何滚动到底部

我正在尝试用Espresso测试NestedScrollView,但出现错误:

“将不会执行操作,因为目标视图与以下一个或多个约束不匹配:至少90%的视图区域显示给用户。”

我知道此错误是因为Android未检测到要单击的按钮,也就是说,我需要滚动到底部才能看到该按钮。我也已经阅读了scrollTo()对NestedScrollView不可用,所以我不能使用它。我想我必须滚动到NestedScrollView的底部才能看到该按钮,我既不确定这一点,也不知道该怎么做。

我想单击红色的按钮,但是它没有可见性

我想单击红色按钮,但它没有可见性。我已经看到了几个堆栈问题和一些教程,但是我不知道如何滚动到嵌套的底部。

应用程序工具栏的代码为:

<?xml version="1.0" encoding="utf-8"?>
        <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/main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            tools:context="com.findandgo.activity.MenuPrincipal"
            >

            <android.support.design.widget.AppBarLayout
                android:id="@+id/appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingTop="@dimen/appbar_padding_top"
                android:theme="@style/AppTheme"
                >


                <android.support.v7.widget.Toolbar

                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll"
                    app:popupTheme="@style/AppTheme.AppBarOverlay"
                    xmlns:app="http://schemas.android.com/apk/res-auto"
                    xmlns:android="http://schemas.android.com/apk/res/android"/>



                    <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    />

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


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



        </android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

NestedScrollView的代码为:

<android.support.v4.widget.NestedScrollView 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/fragment_evento_crear"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="fill_vertical"
    android:background="@drawable/fondo"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".Evento"
    >
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:nestedScrollingEnabled="false"
        android:padding="@dimen/size_20"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin">


        <com.findandgo.custom.CustomFontEditText
            android:id="@+id/idEtEventoNuevoNombre"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/idSpEventoNuevoCategoria"
            android:layout_alignStart="@+id/idSpEventoNuevoCategoria"
            android:layout_below="@id/tool_bar"
            android:hint="@string/sEventoNombre"
            android:textSize="@dimen/size_12"
            app:font="@string/font_name_source_amatic_regular" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-espresso android-nestedscrollview

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

以编程方式滚动到屏幕的末尾

我已经将TapTargetView库实现到我的应用程序中.

传递某个元素后,我需要关注此时屏幕外的下一个视图:

@Override
public void onSequenceStep(TapTarget lastTarget) {
  if (lastTarget.id() == 7) {
     flavorContainer.setFocusableInTouchMode(true);
     flavorContainer.requestFocus();
  }
}
Run Code Online (Sandbox Code Playgroud)

在我在屏幕底部添加广告单元之前,一切都很好.所以现在广告背后会显示必要的元素.

在此输入图像描述

方法requestFocus()仅将布局滚动到必要的视图,但不是在屏幕的末尾.

在此输入图像描述

我需要一种方法将屏幕内容滚动到非常结束,而不仅仅是在屏幕上显示必要的视图.可能吗?

在此输入图像描述

布局结构

<android.support.design.widget.CoordinatorLayout>
<LinearLayout>
<android.support.v4.widget.NestedScrollView> 
<LinearLayout> 
<android.support.v7.widget.CardView> 
<LinearLayout>

</LinearLayout> 
</android.support.v7.widget.CardView> 
</LinearLayout> 
</android.support.v4.widget.NestedScrollView> 
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-nestedscrollview

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