还需要viewflipper在此布局中垂直滚动

时间:2017-07-26 04:57:54

标签: android android-layout android-viewflipper

目前只有我的GridView可滚动,但我也需要我的ViewFlipper可滚动。我需要帮助ViewFlipper垂直滚动

这是我目前的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_grids"
    android:layout_width="match_parent"
    android:overScrollMode="always"
    android:layout_height="match_parent">

    <ViewFlipper
        android:layout_marginTop="56dp"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:autoStart="true"
        android:id="@+id/vf1z"
        android:flipInterval="3000">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            android:background="@drawable/front"
            android:id="@+id/imageViewz"/>

    </ViewFlipper>

    <GridView
        android:numColumns="3"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:id="@+id/grid"
        android:layout_marginTop="208dp"/>

<include layout="@layout/search"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/include">
</include>

</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

您可以在<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_grids" android:layout_width="match_parent" android:overScrollMode="always" android:layout_height="match_parent"> <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" > <ViewFlipper android:layout_marginTop="56dp" android:layout_width="match_parent" android:layout_height="150dp" android:autoStart="true" android:id="@+id/vf1z" android:flipInterval="3000"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" android:background="@drawable/front" android:id="@+id/imageViewz" /> </ViewFlipper> <GridView android:numColumns="3" android:layout_width="fill_parent" android:layout_height="match_parent" android:id="@+id/grid" android:layout_marginTop="208dp" /> </ScrollView> <include layout="@layout/search" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/include"> </include> </RelativeLayout> 中添加布局中的所有元素。

ViewFlipper

或者,如果您只想让ViewFlipper滚动,则可以在ScrollView

中添加Get-ChildItem -Path $source -Recurse -Exclude "web.config","body.css","Thumbs.db"

答案 1 :(得分:0)

您可以使用VerticalViewPager自定义实现

package com.registration;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class RegistrationController
 */
public class RegistrationController extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrationController() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        String name = request.getParameter("fullname");
        String Addr = request.getParameter("address");
        String age = request.getParameter("age");
        String Qual = request.getParameter("qual");
        String Persent = request.getParameter("percent");
        String Year = request.getParameter("yop");
        if(name.isEmpty()||Addr.isEmpty()||age.isEmpty()||Qual.isEmpty()||Persent.isEmpty()||Year.isEmpty())
        {
            RequestDispatcher rd = request.getRequestDispatcher("registration.jsp");
            out.println("<font color=red>OOPS!! YOU MISSED OUT SOME FIELDS. FILL THEM AGAIN</font>");
            rd.include(request, response);
        }
        else
        {
            RequestDispatcher rd = request.getRequestDispatcher("home.jsp");
            rd.forward(request, response);
        }
    }


}

参见@Br​​ett提供的先前答案

Android: Vertical ViewPager