Place gallery with text

2

I'm trying to put a gallery of products in my app, and I wanted the image and the text below, I'm using the viewpager, but the text is on the side, and the images are far from each other, so there's a imagen wanted to appear at least 2 with the text below. See the codes:

ViewPagerMain

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Item     

<TextView
    android:id="@+id/ranklabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/ranklabel" />

<TextView
    android:id="@+id/rank"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/ranklabel" />

<TextView
    android:id="@+id/countrylabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/ranklabel"
    android:text="@string/countrylabel" />

<TextView
    android:id="@+id/country"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/rank"
    android:layout_toRightOf="@+id/countrylabel" />

<TextView
    android:id="@+id/populationlabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/countrylabel"
    android:text="@string/populationlabel" />

<TextView
    android:id="@+id/population"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/country"
    android:layout_toRightOf="@+id/populationlabel" />

<ImageView
    android:id="@+id/flag"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:background="#000000"
    android:padding="1dp" />

How do I put the closest images and the text below?

    
asked by anonymous 09.01.2015 / 14:41

1 answer

1

Well ... Your question is very vague, but when displaying only XML, I can answer that there is only <ImageView , ie ONLY ONE IMAGE. Add another <ImageView to your xml and for the text to be down, in column form, remove android:layout_toRightOf , <TextView put something like this:

<ImageView
    android:id="@+id/flag"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:padding="1dp" />

<ImageView
    android:id="@+id/flag2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:padding="1dp" />


<TextView
    android:id="@+id/ranklabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/ranklabel" />

<TextView
    android:id="@+id/rank"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

<TextView
    android:id="@+id/countrylabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/ranklabel"
    android:text="@string/countrylabel" />

<TextView
    android:id="@+id/country"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/rank" />

<TextView
    android:id="@+id/populationlabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/countrylabel"
    android:text="@string/populationlabel" />

<TextView
    android:id="@+id/population"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/country" />

REMEMBER that it is also necessary to add more Java code to this new ImageView. It's no use just adding this ImageView in XML.

    
13.01.2015 / 18:50