标签: android-scrollview

如何禁用scrollView的fling

我想禁用滚动型的扫视姿势,它似乎并没有工作.我认为这将是作为创造延伸滚动视图和@一个基本的类一样简单OverridingonFling方法.但eclipse给我一个错误,删除@Override:

任何想法如何禁用fling

public class ScrollViewNoFling extends ScrollView {

    /**
     * @param context
     * @param attrs
     * @param defStyle
     */
    public ScrollViewNoFling(Context context) {

        super(context);
        // TODO Auto-generated constructor stub
    }
    public ScrollViewNoFling(Context context, AttributeSet attrs) {

        super(context, attrs);
        // TODO Auto-generated constructor stub
    }
    public ScrollViewNoFling(Context context, AttributeSet attrs, int defStyle) {

        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

   @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
    {
        return false;
    } …
Run Code Online (Sandbox Code Playgroud)

android android-scrollview

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

一起控制两个ViewPager

我需要将两个ViewPager同步在一起.要求类似于滚动ViewPager-1,ViewPager-2也应该滚动一定量.下面的图片将使您更清楚我的问题.

在此输入图像描述

你也可以帮我一些教程链接.谢谢.

android android-layout android-scrollview android-viewpager android-scroll

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

ScrollView adds large space at the bottom

My main Activity has a number of buttons, that fit below each other on a large Tablet screen, but not on a smaller Phone screen. I added a ScrollView, so that the user can scroll down to the other buttons if the screen size requires it:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:background="@drawable/bg"
          android:gravity="center_horizontal">

    <TextView
        android:id="@+id/trackSelectorText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"/>

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

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

        <Button                    
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="foo" />
        <!-- More buttons -->
        </LinearLayout>
    </ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

This …

android android-scrollview

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

Android Twitter - 下拉刷新和隐藏标签

如何将list-view的滚动与其他视图同步,我也希望像twitter应用程序一样实现pull-down-refresh.在Twitter应用程序中,在向上滚动列表视图时,标签栏和底部视图会隐藏,如果向下滚动,下拉刷新视图就会出现.

下面的图像表示:没有滚动列表 没有滚动列表

下面的图像表示:向上滚动列表:标签栏和底部视图获取隐藏 向上滚动列表!

下面的图像表示:向下滚动列表:下拉刷新来了 向下滚动列表!

android android-custom-view android-animation android-listview android-scrollview

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

如何为ScrollView设置OnClickListener?

我正在开发一个拥有viewpager的android项目.我为我的viewpager写了一个适配器,我的适配器由s scrollview和里面的一些视图组成.

我想当用户点击滚动视图时,会发生一些事情(我也写了这部分并测试它并且它有效).

我为我的scrollview实现了onClickListener,但是当用户点击它时它不会被触发.

我已经读过这个,但这对我不起作用.

我的onClickListener代码就在这里

rootView = inflater.inflate(R.layout.level_selector_list_view_adapter, container, false);
ScrollView scroll = (ScrollView) rootView.findViewById(R.id.level_selector_view_scroll_view);

scroll.setOnClickListener(new OnClickListener()
{
        @Override
        public void onClick(View arg0)
        {
            Log.e(MainActivity.WATERMELON_TAG, "Click!!!");
        }
});
Run Code Online (Sandbox Code Playgroud)

我的布局代码是这样的:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/level_selector_values_main_page_view_pager_width"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/level_selector_view_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    tools:ignore="UselessParent" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="false"
        tools:ignore="UselessParent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:clickable="false"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/level_selector_view_pager_adapter_level_logo"
                android:layout_width="@dimen/level_selector_values_view_pager_adapter_level_logo_width"
                android:layout_height="@dimen/level_selector_values_view_pager_adapter_level_logo_height"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="@dimen/level_selector_values_view_pager_adapter_level_logo_top_margin"
                android:clickable="false"
                android:scaleType="fitXY"
                tools:ignore="ContentDescription" />

            <TextView
                android:id="@+id/level_selector_view_pager_adapter_level_name"
                android:layout_width="@dimen/level_selector_values_view_pager_adapter_level_name_width"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="@dimen/level_selector_values_view_pager_adapter_level_name_top_margin"
                android:clickable="false"
                android:gravity="center"
                android:textColor="@color/level_selector_values_level_name_font_color"
                android:textSize="@dimen/level_selector_values_level_name_font_size" /> …
Run Code Online (Sandbox Code Playgroud)

java android android-fragments android-scrollview onclicklistener

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

滚动视图内的Android列表视图自动滚动问题

我有一个Android布局设置,我有一个ScrollView与一些元素,在里面,我有一个ListView.我在滚动视图中使用StackOverflow的答案Android列表视图来实现此功能,并且它工作正常.我的ListView位于TextView,ImageView等一些元素之下.问题是,当页面出现时,ListView会自动滚动,以便listView中的第一项位于顶部(即整个scrollview会滚动显示listview第一项).如何避免这种自动滚动?

android android-listview android-scrollview

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

添加新片段后,Android会滚动到底部

我有一个带有LinearLayout的应用程序,从上到下,随着时间的推移,矩形片段会在下面添加.

在某些时候屏幕已满,新片段被"隐藏"在屏幕视图之外.我想要做的是每次添加新片段时使应用程序滚动到底部.

每次按下活动中的按钮或检查上面片段中的复选框时,都会添加一个片段.所以我在onClickListeners和片段的onCreateView上尝试了以下内容:

        fm.beginTransaction().add(R.id.activity_uhf_layout, fragment).commit(); //Adding fragment



        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                scrollView.scrollTo(0, scrollView.getBottom());
            }});
Run Code Online (Sandbox Code Playgroud)

这有时会起作用,片段会被添加并且屏幕会向下滚动,但它会像1/8倍一样.

我尝试过其他的东西,比如:

        scrollView.post(new Runnable() {
        @Override
        public void run() {
            scrollView.scrollTo(0, scrollView.getBottom());
            }
        });
Run Code Online (Sandbox Code Playgroud)

这基本上给出了相同的结果,我试过没有Runnable帖子,这根本不起作用.

我得到的结果是布局只向下滚动到已经存在的片段的底部,而不是一直到片段管理器刚刚添加的新片段的末尾.

对我来说,似乎即使添加了片段,LayoutManager也没有真正"检测到它"或类似的东西,但是如何绕过它,我不是很确定.

android android-fragments android-scrollview

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

将EditText设置为动画或滚动到屏幕顶部

我有一个DialogFragment,其中是一个带有一些EditText字段的ScrollView.如果用户按下最后一个,则应将其移动到标题下方的对话框的顶部.如果我只使用scrollView.smoothScrollTo(0,view)滚动到此字段,它只会出现在软键盘上,但仍显示最后一个字段上的其他字段.如果我将所有字段的可见性设置为"GONE"以上,它可以正常工作,但用户无法向后滚动,但我需要它.我不知道在Android上是否可行.有人可以帮帮我吗?我花了三天时间解决这个问题,但找不到解决方案.任何帮助将不胜感激!

编辑:截图这就是我所拥有的: 在此输入图像描述

我需要什么:

在此输入图像描述

android android-animation android-edittext android-scrollview

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

如何设置ListView高度取决于ScrollView中的项目

我正在尝试添加listView内部scrollView和.

问题是我无法以ListView编程方式设置高度并正确地重绘ScrollView,因为在更改高度之前,它下面的项目仍处于旧位置.

XML

<ScrollView
    android:id="@+id/movie_detail_scroll_view"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/movie_detail"
        style="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipChildren="false">
        ...........
        <ListView
            android:id="@+id/trails_list_view"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/movie_videos_container"
            android:choiceMode="none"/>
        <include
            android:id="@+id/movie_reviews_container"
            layout="@layout/partial_movie_reviews"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/trails_list_view"/>
        ............
    </RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我用来调整listView大小的方法:

/**
 * Sets ListView height dynamically based on the height of the items.
 *
 * @param listView to be resized
 * @return true if the listView is successfully resized, false otherwise
 */
public static boolean setListViewHeightBasedOnItems(ListView listView, ViewGroup …
Run Code Online (Sandbox Code Playgroud)

android listview android-layout android-scrollview

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

无法在SlidingUpPanelLayout Xamarin Android中使用ScrollView布局

我在我的代码中使用了这个库.基本上我在SlidingUp面板布局上有一个ScrollView.代码如下:

<cheesebaron.slidinguppanel.SlidingUpPanelLayout
                android:id="@+id/sliding_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="bottom">
                <android.support.v4.view.ViewPager
                    android:id="@+id/HomeFrameLayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
                <ScrollView
                    android:id="@+id/slidingPanelScrollView"
                    android:layout_height="match_parent"
                    android:layout_width="match_parent"
                    android:background="@android:color/transparent"
                    android:clickable="true"
                    android:focusable="false">
                    <RelativeLayout
                        android:layout_height="match_parent"
                        android:layout_width="match_parent">
                        <RelativeLayout
                            android:id="@+id/cardHolderRelativeLayout"
                            android:layout_height="match_parent"
                            android:layout_width="380dp"
                            android:background="@android:color/transparent"
                            android:layout_centerHorizontal="true"
                            android:padding="10dp">
                            <LinearLayout
                                android:id="@+id/linearLayout1"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#FF0000"
                                android:layout_marginBottom="15dp" />
                            <LinearLayout
                                android:id="@+id/linearLayout2"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#00FF00"
                                android:layout_marginBottom="15dp"
                                android:layout_below="@id/linearLayout1" />
                            <LinearLayout
                                android:id="@+id/linearLayout3"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#0000FF"
                                android:layout_marginBottom="15dp"
                                android:layout_below="@id/linearLayout2" />
                            <LinearLayout
                                android:id="@+id/linearLayout4"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#0000FF"
                                android:layout_marginBottom="15dp"
                                android:layout_below="@id/linearLayout2" />
                        </RelativeLayout>
                    </RelativeLayout>
                </ScrollView>
            </cheesebaron.slidinguppanel.SlidingUpPanelLayout>
Run Code Online (Sandbox Code Playgroud)

我想要实现的是,如果展开SlidingUpPanelLayout,用户应该能够滚动ScrollView.如果ScrollView滚动到顶部(用户在手机上向下滚动)并且用户继续向下滚动,则SlidingUpPanelLayout应该折叠.

我实现了以下代码:

_slidingUpPanelLayout.NestedScrollingEnabled = true;

        _scrollView.ViewTreeObserver.ScrollChanged += (sender, e) => 
        {
            var y = _scrollView.ScrollY;
            if (y …
Run Code Online (Sandbox Code Playgroud)

c# android xamarin.android android-scrollview xamarin

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