Search code examples
androidandroid-viewpagerimage-gallerydivider

How to hide Image gallery viewpager divider


I have a image gallery and in this image gallery I have 3 pictures when I swipe then there is this middle line padding or divider I think it maybe padding. How I can make it hidden son pictures will follow eachother without a space.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"

tools:context="com.example.Test.MainActivity" 
 android:background="#FFFFFF">
<RelativeLayout
    android:id="@+id/mainlayoutChild"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#eeceee"

    android:orientation="vertical"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">
    <RelativeLayout
        android:id="@+id/level1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff"
        android:orientation="vertical"
        android:divider="@android:color/transparent"
        android:dividerPadding="0dp"
        >

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:divider="@android:color/transparent"
            android:dividerPadding="0dp"

            />



        <RelativeLayout
            android:id="@+id/viewPagerIndicator"
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:layout_alignParentBottom="true"
            android:layout_gravity="center_horizontal|bottom"
            android:gravity="center">

            <LinearLayout
                android:id="@+id/viewPagerCountDots"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerHorizontal="true"
                android:gravity="center"
                android:orientation="horizontal" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:id="@+id/buttons"
            android:layout_height="wrap_content"
            android:layout_above="@+id/viewPagerIndicator"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true">
            <Button
                android:id="@+id/button_login"
                style="@style/uppeningFacebookLoginButton"
                android:layout_width="75dp"
                android:layout_height="75dp"
                android:alpha="0.77"
                android:layout_marginLeft="10dp"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <Button
                android:id="@+id/buttonGsd"
                style="@style/uppeningVkLoginButton"
                android:layout_width="75dp"
                android:layout_height="75dp"
                android:layout_marginRight="10dp"
                android:layout_alignParentRight="true"
                android:alpha="0.77"
                android:layout_alignParentEnd="true" />

            <Button
                android:id="@+id/buttonGs"
                style="@style/uppeningGoogleLoginButton"
                android:layout_width="75dp"
                android:layout_height="75dp"
                android:alpha="0.77"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true" />


        </RelativeLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Text"
            android:id="@+id/textView6"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="70dp"
            android:layout_marginStart="70dp"
            android:layout_marginTop="82dp" />


    </RelativeLayout>
</RelativeLayout>


<ImageView
    android:id="@+id/company_logo"
    android:layout_width="match_parent"
    android:layout_height="75dp"
     android:visibility="gone"
    android:src="@drawable/ruhesi_logoruhesismall" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/ruhesi_login"
    android:layout_below="@+id/company_logo"
    android:id="@+id/loginView"
    android:textColor="@android:color/black"
    android:layout_centerInParent="true"
    android:visibility="gone"
    android:layout_gravity="center_horizontal|top"/>

  <RelativeLayout
    android:id="@+id/relative"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
  android:visibility="gone"
    android:layout_marginTop="19dp"
    android:orientation="horizontal"
    android:scaleType="fitCenter"
    android:layout_centerInParent="true"
    android:padding="10dp" >
  </RelativeLayout>

</RelativeLayout>

enter image description here


Solution

  • Did you try to make your activity Full screen?

    <activity android:name=".YourActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
    

    If yes try to eliminate it programmaticaly because you cannot from the xml.

    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setPageMargin(int margin); // 0 in your case
    

    If you want some drawable in that margin:

    pager.setPageMarginDrawable(drawable d)
    pager.setPageMarginDrawable(int resId)
    

    If this does not work too, take a look at this. I have not tried it yet but maybe you can and let me know :)