ViewFlipper not showing any images

228 views Asked by At

I have added 2 image views inside ViewFlipper, but no image is being shown up. On setting the background color of View Flipper the color is shown but no image is being projected. And this is a very basic project. Please tell me the reason. I am attaching both Java and XML file, please have a look

MainActivity.java

public class MainActivity extends AppCompatActivity {
        ViewFlipper viewFlipper;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            viewFlipper = findViewById(R.id.viewFlipper);

            viewFlipper.setAutoStart(true);
            viewFlipper.setFlipInterval(3000);
            viewFlipper.startFlipping();
        }
    }

activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
        <ViewFlipper
            android:id="@+id/viewFlipper"
            android:layout_width="match_parent"
            android:layout_height="281dp"
            android:inAnimation="@anim/right_to_left"
            android:outAnimation="@anim/right_to_left"
            android:background="@color/colorPrimaryDark"
            android:padding="10dp"
            android:visibility="visible">


            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:srcCompat="@tools:sample/backgrounds/scenic" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:scaleType="fitXY"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/f2" />
        </ViewFlipper>


    </android.support.constraint.ConstraintLayout>
0

There are 0 answers