有什么方法可以将ListView的弹跳效果添加到常规scrollview中?通过弹跳我的意思是当你触到列表的底部时橡皮筋就像效果一样.
我一直试图设置滚动视图的初始位置,但没有找到方法.有没有人有任何想法?此外,我还有一个GoogleMaps片段作为滚动视图的子项.
谢谢,
瑞安
我正在尝试在ScrollView中显示水平Recyclerview项目和垂直Recyclerview项目
即使我使用android:Scrollview也无法正常工作:fillViewport ="true"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//Horizontal Recyclerview items
<RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RecyclerView>
//vertical Recyclerview items
<RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"></RecyclerView>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我遇到了包含一个包含LinearLayout的ScrollView的Fragment问题.我正在尝试创建一种效果,其中LinearLayout具有白色背景,看起来像一张纸在彩色背景上滚动.我试图实现这一目标的方法是让ScrollView占据片段的整个空间,然后内部的LinearLayout必须android:layout_margin="16dp"创建"纸张"周围的空间.
这样,ScrollView的滚动条显示在彩色背景区域中,顶部的边距与内容一起滚动,底部的边距仅在到达末尾时滚动.
不幸的是,在这种配置中,ScrollView不会一直滚动到最后,实际上会截断底部的非常少量的文本.我怀疑ScrollView没有在其垂直滚动距离中考虑其孩子的边距.为了解决这个问题,我将LinearLayout包装在一个解决问题的FrameLayout中,但似乎是多余的.关于如何消除这个不需要的容器的任何指示将不胜感激.
注意:android:padding="16dp"在ScrollView上设置并删除边距不会产生所需的效果,因为无论滚动位置如何,填充都会连续显示在所有四个边上.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
tools:context=".ArticleFragment" >
<!-- This FrameLayout exists purely to force the outer ScrollView to respect
the margins of the LinearLayout -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:layout_margin="16dp"
android:background="@color/page_background" >
<TextView
android:id="@+id/article_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textIsSelectable="true" />
<TextView
android:id="@+id/article_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textIsSelectable="true" />
</LinearLayout>
</FrameLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) android android-layout android-linearlayout android-scrollview
我有一个简单的布局,顶部有一个名字,还有一个我希望位于屏幕底部的按钮,或者我想要添加更多项目的按钮.
所以我使用带有LinearLayout的ScrollView,如下所示:
<ScrollView 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"
android:background="@android:color/white"
android:fillViewport="true"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".ItemDetailActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name -->
<RelativeLayout
android:id="@+id/top_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top" >
<TextView
android:id="@+id/name_label"
style="@style/Header_Label_TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/name" />
<TextView
android:id="@+id/name_value"
style="@style/Value_Label_TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/name_label" />
</RelativeLayout>
<!-- button -->
<RelativeLayout
android:id="@+id/ButtonLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<Button
android:id="@+id/add_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:onClick="editItem"
android:text="@string/button_edit" />
</RelativeLayout>
<requestFocus />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:

如何使按钮出现在屏幕底部或更远处.在线搜索,大多数答案是设置`android:fillViewport ="true",但这没有帮助.我究竟做错了什么?
android android-layout android-linearlayout android-scrollview android-relativelayout
我有一个用于测试目的的网页(https://storage.googleapis.com/htmltestingbucket/nested_scroll_helper.html),它只打印html在固定标题中捕获的滚动事件的计数器
当Android WebView是片段中唯一可滚动的元素时,一切都很好,WebView将滚动事件发送到页面
如果我想在WebView的上方和下方添加原生元素,那么事情会变得复杂得多.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="SOMETHING ABOVE THE WEBVIEW" />
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="SOMETHING BELOW THE WEBVIEW" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我知道在ScrollView中使用WebView并不好,但我必须在html文档中提供混合内容和正确滚动事件的单一滚动体验.我发现了很多关于此事的问题,但我能够创建一个完整的端到端解决方案
此外,我知道lint有一个官方的检查:
NestedScrolling ---------------摘要:嵌套滚动小部件
优先级:7/10严重性:警告类别:正确性
滚动窗口小部件(如ScrollView)不应包含任何嵌套滚动窗口小部件,因为它具有各种可用性问题
然而,我无法在本机中实现Web视图内容,因此我需要另一种方法来实现
我有一个recyclerView,它包含一个自定义视图列表.当我单击recyclerView项时,它会被展开,提供更多信息.另一次点击此视图(或另一个视图)将关闭当前视图.提供的默认动画SimpleItemAnimator似乎不合适.所以,我试着animateChange像我一样自己实现:
public class CustomItemAnimator extends CustomDefaultItemAnimator {
private static final int FADE_IN = 1;
private static final int FADE_OUT = 2;
private ItemHolderInfo getItemHolderInfo(RecyclerView.ViewHolder viewHolder, MoveInfo moveInfo) {
moveInfo.stuff.clear();
ViewGroup content_container = (ViewGroup) viewHolder.itemView.findViewById(R.id.item_content);
for (int i = 0; i < content_container.getChildCount(); i++) {
View view = content_container.getChildAt(i);
if (view.getVisibility() == View.VISIBLE) {
moveInfo.stuff.put(view.getId(), new Pair<>(view.getTop(), view.getBottom()));
}
}
moveInfo.stuff.put(viewHolder.itemView.getId(), new Pair<>(viewHolder.itemView.getTop(), viewHolder.itemView.getBottom()));
moveInfo.stuff.put(content_container.getId(), new Pair<>(content_container.getTop(), content_container.getBottom()));
return moveInfo;
}
@NonNull
@Override
public ItemHolderInfo recordPreLayoutInformation(@NonNull RecyclerView.State …Run Code Online (Sandbox Code Playgroud) android android-animation android-scrollview android-recyclerview
所以我一直在ScrollView中使用ConstraintLayout开发这个布局.它工作正常,但现在我遇到了问题.我必须在屏幕外扩展布局.我可以在设计模式下滚动,但如果没有它被卡在顶部,我就无法添加任何内容.约束是针对早期的对象,而不是我正在添加的当前对象.
我可以在Blueprint模式下添加约束,但看起来我无法在蓝图模式下滚动ScrollView.这甚至可能吗?使用Android Studio 2.2(发布)和constraint-layout:1.0.0-alpha8
我尝试在设计模式下这样做,但它不滚动.有任何想法吗?
使用ConstraintLayout正常滚动会导致约束停留在同一位置.
编辑:
已更新alpha9但仍未解决
编辑2:
beta1也不起作用.AS 2.2.2.
编辑3:
样本布局:
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/sampleButton"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="HardcodedText">
<android.support.constraint.ConstraintLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- ETC constraints -->
</android.support.constraint.ConstraintLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
android android-layout android-scrollview android-studio-2.2 android-constraintlayout
我在片段中实现了新的datepicker.这包含在scrollview中.当我尝试使用日期选择器时,我必须先点击并按住屏幕上的某个位置,然后才能滚动日期选择器calader,让我们说可能.
有没有办法来解决这个问题?
即时通讯使用此时间戳:

我加载它像这样:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollView2"
android:layout_row="11"
android:fillViewport="true"
android:background="#162229"
android:layout_column="2"
android:paddingBottom="20dp">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#162229"
android:orientation="vertical" >
<DatePicker
android:id="@+id/datePicker1"
android:layout_width="wrap_content"
android:background="#162229"
android:calendarTextColor="#fff"
android:layout_height="wrap_content"
android:calendarViewShown="false" > <!-- style="@style/date_picker_style" -->
</DatePicker>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我Recyclerview这是在Coordinatorlayout> NestedScrollview>ViewPager并ViewPager有3个片段,一个具有正与帮助图片库Recyclerview。每当我尝试向上或向下滚动时,它根本不滚动。我已经设置好了photosRecycler.setNestedScrollingEnabled(false);,一旦我删除这条线,我就会让滚动只向下工作,当我试图向上移动时,它会随着父级向上移动Nestedscrollview。
我的布局管理器也将 StaggeredGrid 显示为 Grid 我需要获得这种布局
这是我的 Nestedscrollview 父布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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:background="?android:attr/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground">
<ImageView
android:layout_width="match_parent"
android:layout_height="500dp"
android:src="@color/custom_transparent_colorBlack"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="128dp"
android:layout_height="128dp"
app:layout_constraintBottom_toBottomOf="@+id/coverPhoto"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/coverPhoto"
app:layout_constraintVertical_bias="0.44"
tools:srcCompat="@tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/up_NestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior" …Run Code Online (Sandbox Code Playgroud) java android android-scrollview android-gridlayout android-recyclerview