How to add space between items in horizontal sroll view

By KarthikKPN

enter image description here

I am working in a app presently and i designed the following screen. In this screen, i need to give some spacing between the horizontal scroll view items. I tried giving margin to the child items but it didn’t work!

In the above picture, Cat–>D0g–>Fish is my Horizontal Scroll view

My Main Activity xml:

 <HorizontalScrollView
        android:id="@+id/HorizontalScroll"
        android:layout_width="wrap_content"
        android:layout_below="@+id/topLinearLayout"
        android:layout_height="wrap_content">
        <LinearLayout
            android:id="@+id/horizontalLL"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:dividerPadding="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="5dp"
            android:orientation="horizontal"
           >
        </LinearLayout>
    </HorizontalScrollView>

My Custom xml layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:background="@drawable/white_border"
    android:orientation="vertical">
    <ImageView
        android:id="@+id/animalImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher" />
    <TextView
        android:gravity="center"
        android:id="@+id/textView"
        android:textSize="12dp"
        android:textColor="@color/colorBlack"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Animal" />
</LinearLayout>

My Activity Java code:

 LayoutInflater inflater = LayoutInflater.from(ListingActivity.this);
        for (int i = 0; i < animalsNameList.size(); i++) {
            View custLayout = inflater.inflate(R.layout.customrow, null, false);
            TextView label = (TextView) custLayout.findViewById(R.id.textView);
            ImageView value = (ImageView) custLayout.findViewById(R.id.animalImage);
            label.setText(animalsNameList.get(i));
            value.setImageResource(imagelist.get(i));
            horizontalLL.addView(custLayout);
        }

Is that something am i missing ?

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273