Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7721995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:04:12+00:00 2026-06-01T04:04:12+00:00

I am making an android app in which i am trying to slide between

  • 0

I am making an android app in which i am trying to slide between different views using viewflipper. I took help from here. I tried experimenting with the code but I have a problem now. I have a scrollview in one of my layouts, due to which the viewflipper is not switching between the views. Can anyone please help me? This is my xml layout code with three screens to swipe through:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:orientation="vertical" >

    <ViewFlipper
        android:id="@+id/details"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#ffffff"
            android:orientation="vertical" >


            <!-- <ScrollView -->
            <!-- android:id="@+id/flotest" -->
            <!-- android:layout_width="match_parent" -->
            <!-- android:layout_height="match_parent" -->
            <!-- android:background="#FFFFFF" > -->


            <!-- <LinearLayout -->
            <!-- android:id="@+id/LR1" -->
            <!-- android:layout_width="match_parent" -->
            <!-- android:layout_height="match_parent" > -->


                    <TextView
                        android:id="@+id/floText"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:text="@string/flo_garbage"
                        android:textColor="#000000" />
<!--                 </LinearLayout> -->
<!--             </ScrollView> -->
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#ffffff"
            android:orientation="vertical" >

            <RelativeLayout
                android:id="@+id/rl1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:text="@string/current_city"
                    android:textColor="#000000" />

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentTop="true"
                    android:src="@drawable/disclosure" />
            </RelativeLayout>

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#ffffff"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/floText"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="FRIENDS PAGE"
                android:textColor="#000000"
                android:textSize="50dip" />
        </LinearLayout>
    </ViewFlipper>

</LinearLayout>

The above code works perfectly fine but if i uncomment the scrollview part, the sliding does not work. This is my Activity code :

   public class main extends Activity implements OnTouchListener {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            layMain = (LinearLayout) findViewById(R.id.layout_main);
            layMain.setOnTouchListener((OnTouchListener) this);

        }

        public boolean onTouch(View arg0, MotionEvent arg1) {

            // Get the action that was done on this touch event
            switch (arg1.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                // store the X value when the user's finger was pressed down
                downXValue = arg1.getX();
                break;
            }

            case MotionEvent.ACTION_UP: {
                // Get the X value when the user released his/her finger
                float currentX = arg1.getX();

                // going backwards: pushing stuff to the right
                if (downXValue < currentX) {
                    ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);
                    vf.setInAnimation(AnimationUtils.loadAnimation(this,
                            R.anim.push_left_in));
                    vf.setOutAnimation(AnimationUtils.loadAnimation(this,
                            R.anim.push_right_out));
                    if (screenmiddle) {
                        vf.showNext();
                        screenleft = true;
                        screenmiddle = false;
                        screenright = false;
                    } else if (screenright) {
                        vf.showNext();
                        screenleft = false;
                        screenmiddle = true;
                        screenright = false;
                    }
                }

                // going forwards: pushing stuff to the left
                if (downXValue > currentX) {

                    ViewFlipper vf = (ViewFlipper) findViewById(R.id.details);

                    vf.setInAnimation(AnimationUtils.loadAnimation(this,
                            R.anim.push_right_in));
                    vf.setOutAnimation(AnimationUtils.loadAnimation(this,
                            R.anim.push_left_out));
                    if (screenleft) {
                        vf.showPrevious();
                        screenleft = false;
                        screenmiddle = true;
                        screenright = false;
                    } else if (screenmiddle) {
                        vf.showPrevious();
                        screenleft = false;
                        screenmiddle = false;
                        screenright = true;
                    }
                }
                break;
            }
            }

            // if you return false, these actions will not be recorded
            return true;
        }


    }

I know this a common problem as in this and this but i could not find any solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:04:13+00:00Added an answer on June 1, 2026 at 4:04 am

    Instead of using a scrolling TextView its better to use a ListView because ListView has scrolling enabled in it automatically. So the same code above works perfectly fine with a ListView instead of the TextView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an android app in which I am trying to lazyload and
I am making an android app in which I need to make different tables
I am making an android app in which i am using google maps which
I'm making an OpenGLES Android app using Android NDK, expanding from android's gljni example,
I'm making a Android app that basically plays video from a website on the
I'm making a simple drawing app on Android. I'm using the FingerPaint.java provided with
I am making an android application, which takes an image from camera and then
i am making android UI (using Relative Layout)in which, i need to set one
I am making an android app in which i have to show Hash Tag
I am making an android app in which i want to make a dynamic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.