Search code examples
javaandroid-studioscrollview

Android Studio ScrollView only show visible images


I've created a scrollview that scrolls through images, but even if some of the images aren't visible it still scrolls as if they were. Is there a way to make the scroll only scroll through the visible images?


Solution

  • Put the following line in imageview xml

    android:visibility="gone"
    

    Then the full code like this

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:src="@drawable/image" />
    

    As well as you can also do that with programmatically .

    ImageView imageview = findViewById(R.id.imageView);
    imageview.setVisibility(View.GONE); 
    

    Hope you helpful.