标签: android-scrollview

ScrollView滚动到底部时加载更多数据

我有一个带有dinamically加载内容的scrollView.有时可能会有很多内容,所以我想在用户滚动到底部时加载更多内容.

我找到了合适的方法,发现了两个:

onScrollChanged() 
Run Code Online (Sandbox Code Playgroud)

getScrollY()
Run Code Online (Sandbox Code Playgroud)

但我不知道如何将它用于我的目的.请给我一些建议.

android android-scrollview

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

在Android中的Horizo​​ntal ScrollView中显示更多内容

我不确定什么是最好的头衔,但有了图片,我很清楚我想要什么.

我已经实现了Horizo​​ntal Scrollview,我已经定制了它,因为只显示了四个项目,如果用户想看第五个项目,那么他必须滚动它.我成功地完成了它.

但是在android 2.3.3中,当有更多项目时它会在最后显示白色视图,而在android 4.0中它没有显示.见下图:

在此输入图像描述

在android 2.3中看这里,我正在显示白色视图,它清楚地告诉我,有更多按钮,但同样的结果我没有进入android 4.0或更高版本.
任何人都可以帮我如何显示它.

android android-scrollview android-view

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

在较低版本的android中,ScrollView无法正确显示其内容

您可以看到我的scrollview在jellybean和kitkat中显示相同,非常棒:

一 在此输入图像描述

但是我很震惊地看到2.2,2.3.3等较低版本中的相同内容

在此输入图像描述 在此输入图像描述

它似乎显示附加到屏幕上部和下部的文本的一部分.

顺便说一句,中间的线条只是带有灰色背景的文本视图.

你可以看到我的xml代码,抱歉它有点长代码

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/stars"
android:padding="5dp"
android:scrollbars="vertical"
>


<LinearLayout


android:layout_width="match_parent"
android:layout_height="wrap_content"
        android:orientation="vertical" >

 <EditText
     android:id="@+id/editText1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:ems="10"
     android:textColor="#fff"
     android:hint="Type your Full Name here"
     android:inputType="textPersonName"
     android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " >

     <requestFocus />
 </EditText>

 <Button
     android:id="@+id/button1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:background="#330000"
     android:onClick="showresult"
     android:textColor="#ffffff"
     android:alpha=".8"
     android:text="Show My Fortune" />

 <TextView
     android:id="@+id/textView13"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textColor="#ffffff"
     android:textAppearance="?android:attr/textAppearanceSmall" />

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal" 
     android:baselineAligned="false">

     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="1" 
         android:orientation="horizontal"
         >

         <TextView
             android:id="@+id/textView1"
             android:layout_width="20dp"
             android:layout_height="wrap_content"
             android:textColor="#ffffff"
             android:textSize="18sp"
              />

         <TextView
             android:id="@+id/textView2"
             android:layout_width="50dp"
             android:layout_height="wrap_content"

             android:textColor="#ffffff"
             android:textSize="18sp" …
Run Code Online (Sandbox Code Playgroud)

android textview android-layout android-2.3-gingerbread android-scrollview

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

ScrollView 中的可滚动 MultiLine TextView(不涉及触摸交互)

我创建了一个滚动视图,中间有一个多行(可滚动)的 EditText。当编辑该视图并添加超出允许高度的行时,它会按预期滚动。但是,整个容器的父滚动视图也会像跟随文本一样滚动。

    <ScrollView
    p1:minWidth="25px"
    p1:minHeight="25px"
    p1:layout_width="match_parent"
    p1:layout_height="match_parent"
    p1:background="#F7F3DE"
    p1:id="@+id/scrollview">
    <RelativeLayout
        p1:layout_width="match_parent"
        p1:layout_height="match_parent"
        p1:clickable="true"
        p1:focusableInTouchMode="true"
        p1:id="@+id/realtiveLayout">
        <EditText
                p1:id="@+id/editText"
                p1:focusableInTouchMode="true"
                p1:layout_width="match_parent"
                p1:layout_height="150dp"
                p1:hint="Comments"
                p1:background="#00000000"
                p1:textSize="16sp"
                p1:textColor="#555555"
                p1:gravity="top"
                p1:minLines="5"
                p1:maxLines="5"
                p1:inputType="textCapSentences|textMultiLine"
                p1:scrollHorizontally="false"
                p1:layout_marginTop="5dp"
                p1:textColorHint="#A9A9A9" />
        </RelativeLayout>
    </ScrollView>
Run Code Online (Sandbox Code Playgroud)

有没有人看到或知道这个问题的解决方案?

(注意:这不是我已经理解的如何通过触摸滚动一个而不是另一个的问题。这是一个在 EditText 内键入时主滚动视图移动的问题,即使文本没有降低而是滚动.

android android-edittext android-scrollview xamarin

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

使用ConstraintLayout时,ScrollView的底部被剪裁

我有一个问题使用ScrollView内部ConstraintLayout(constraint-layout:1.0.0-beta3)

我的ScrollView的内容没有完全显示.

这是我的布局:

<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_test"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:background="#212121">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Constraint Layout"
            android:textSize="45sp"/>

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/header"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent">

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

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="BUTTON"
                android:layout_marginTop="800dp"/>


        </LinearLayout>

    </ScrollView>

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

这是结果

在此输入图像描述

正如您所看到的那样,按钮不可见,我到达了ScrollView的底部.

它似乎适用于LinearLayout,下面是布局

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_test"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#212121">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Linear Layout"
            android:textSize="45sp"/>

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

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

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android scrollview android-scrollview android-constraintlayout

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

如何使RecyclerView在NestedScrollView中进行回收?

我试图将包括在内的几种观点RecyclerView纳入NestedScrollView。我曾经用过setNestedScrollingEnabled(false),它对于小型数据集看起来不错,但对于大型数据集却开始变得迟钝。

在花了一些时间记录该onCreateViewHolder()方法之后,我了解到回收者视图会像旧的一样立即创建它们ListView。我试图在RecyclerView文档中找到这种行为的原因,但是我在ScrollView description中找到了:

永远不要将ScrollView与ListView一起使用,因为ListView负责其自身的垂直滚动。最重要的是,这样做会挫败ListView中处理大型列表的所有重要优化,因为它有效地迫使ListView显示其整个项目列表,以填充ScrollView提供的无限容器。

我希望这NestedScrollView可以解决问题,但事实并非如此。

是否有任何方法,例如,使用一些自定义项LayoutManagerRecyclerView优化视图回收?

Ps当然,我知道getItemViewType(int pos)使用这种技术添加自定义页眉和页脚的方法和可能性,但是对我来说这似乎是一个丑陋的解决方法。是的,我目前正在使用它,因为拥有比这样大的性能问题更难维护的代码更好。

optimization android recycle android-scrollview android-recyclerview

6
推荐指数
0
解决办法
2020
查看次数

滚动条中startScroll背后的逻辑?

startScroll()在这个文档中没有想到.

它说:

正数会将内容滚动到左侧.

我不明白.如果0总是在左侧,为什么向左滚动?如果是否定的,它将滚动到右侧.

但为什么?我很难绕过它.它背后的逻辑是什么?为什么要向左转?

在游戏和图形编程中,0将始终为左上角或左下角,但它始终位于左侧.因此,使用正数向右移动并以负数向左移动是有意义的.但是为什么它在startScroll上有所不同?

我只是问为什么我真的好奇为什么这样设计它.

android scrollview android-scrollview android-view

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

滚动视图中水平回收器视图中的滚动问题

我的主页中有一个滚动视图,在该滚动视图中,每个回收视图的布局有 2 个布局,每个回收视图将水平滚动。当我尝试滚动 recyclerview 时,scrollview 的滚动会被干扰,并且 scrollview 开始在垂直方向滚动。所以我尝试了下面的代码。

mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
        int action = e.getAction();
        switch (action) {
        case MotionEvent.ACTION_MOVE:
            rv.getParent().requestDisallowInterceptTouchEvent(true);
            break;
    }
    return false;
}

@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {

}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }
});
Run Code Online (Sandbox Code Playgroud)

然后我可以在触摸 recyclerview 时控制水平滚动,但是现在的问题是当我触摸 recyclerview 时我无法垂直滚动我的滚动视图。任何建议请。我的确切需求是我需要滚动视图,并且在滚动视图内部几乎没有回收器视图,它将像谷歌 Play 商店应用程序一样工作。

在此处输入图片说明

这是我的布局

<com.sothree.slidinguppanel.SlidingUpPanelLayout
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    sothree:umanoPanelHeight="368dp"
    sothree:umanoParallaxOffset="2dp"
    sothree:umanoOverlay="false"
    android:gravity="bottom"
    sothree:umanoFadeColor="#00000000"
    sothree:umanoDragView="@+id/dragView"
    sothree:umanoScrollableView="@+id/svScroll"
    sothree:umanoShadowHeight="0dp">

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

    </LinearLayout>

    <LinearLayout
        android:id="@+id/dragView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android gesture android-scrollview android-recyclerview android-touch-event

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

ScrollView 在 CardView 中不起作用

我已经搜索过了,但没有一个答案对我有帮助。

这是我的布局 xml:

<android.support.v7.widget.CardView
        android:id="@+id/layout_building"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/_8dp"
        app:layout_constraintEnd_toStartOf="@+id/scrollview_nested_fragment_container"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/views_container">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <LinearLayout
            android:id="@+id/layout_building_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"/>

        </ScrollView>

    </android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

我正在LinearLayout通过代码向我的动态添加子视图。我也尝试将ScrollView标签移动到包装,CardView但仍然没有运气。这是限制CardView还是有人知道对此的有效解决方案。

android android-scrollview android-cardview

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

在Android中以编程方式更改ScrollView scrollBarStyle

我正在尝试为Android中的ScrollView的scrollBarStyle实现不同的样式.我很清楚使用了setScrollBarStyle()方法,但是我不知道要访问哪些特定样式.

有人可以提供一些额外的信息吗?

android android-layout android-scrollview android-view

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