小编Gay*_*hri的帖子

在android中的Scrollview中设置Viewpager高度

我必须在scrollview中显示一个viewpager(在pager行中的图像下方的图像和文本).我正在从网上下载图像,文本并在寻呼机行中显示.我在srollview中包含了viewpager以支持横向模式.

 <com.xxx.myapp.android.ui.CustomScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:fadingEdge="none"
    android:fillViewport="true"
    android:gravity="center">

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

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="800dp"
            android:layout_gravity="top"
            android:layout_marginTop="10dp" />  
    </LinearLayout>
</com.xxx.myapp.android.ui.CustomScrollView> 
Run Code Online (Sandbox Code Playgroud)

这是CustomScrollView.问题是如何根据子高度设置视图寻呼机高度,以便我可以滚动屏幕直到视图寻呼机项目结束.如果我将view pager height设置为wrapcontent,则viewpager中不会显示任何内容.如果我设置了800dp,那么我可以看到寻呼机项目,但屏幕上有不必要的滚动.我不希望我的滚动视图滚动超出寻呼机儿童的高度.请帮我.

android android-scrollview android-viewpager

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

在android中自动滚动PullToRefreshScrollview

我在PullToRefreshScrollview中有一个Listview,FrameLayout.我正在将一个片段加载到framelayout中.使用延迟适配器将数据加载到listview中.我可以在listview加载时看到fragment/framelayout.但是,在将数据加载到listview并且framelayout不可见之后,Scrollview会自动滚动到listview的位置.如何将滚动视图滚动到顶部?请帮我.提前致谢

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg"
android:orientation="vertical" >


<com.handmark.pulltorefresh.library.PullToRefreshScrollView
    xmlns:ptr="http://schemas.android.com/apk/res-auto"
    android:id="@+id/ptrScrollView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginBottom="5dp"
    android:layout_weight="1"
    android:paddingBottom="5dp"
    ptr:ptrMode="pullUpFromBottom" >

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

        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </FrameLayout>

        <com.xxxx.yyyy.CustomListView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/app_bg"
            android:focusable="false"  />

        <ProgressBar
            android:id="@+id/spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="gone" />
    </LinearLayout>
</com.handmark.pulltorefresh.library.PullToRefreshScrollView>



 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android scrollview pull-to-refresh

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