Richie681
Richie681

Reputation: 53

How to get overlapping Gallery items?

I have a Gallery with several items in it, and I'm trying to get them positioned so that you can see the edge of the next item. Much like this:

http://imgur.com/mtQvX

Any help on how exactly I would go about positioning?

Upvotes: 1

Views: 333

Answers (1)

skynet
skynet

Reputation: 9908

It sort of depends on how far you want to go with it. It should be possible to do with a simple ScrollView that you add a custom view that holds all the components in the picture you linked.

Here's what your custom layout could look like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="340dp"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="24dp"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="29"
            android:textColor="#ffff0000"
            android:textSize="24dp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="of 30"
            android:textSize="14dp"
            android:textStyle="italic" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="August 24 8:01 AM"
            android:textStyle="italic" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Bruce Pearl&apos;s Show-Cause Pentalty And What It Means For His Coaching Future"
            android:textStyle="bold" />
    </LinearLayout>
</LinearLayout>

And this looks something like

enter image description here

Beyond that, if you wanted to do things like make it snap to the edges of your custom views, or something like that, then you might want to look here and here.

Upvotes: 1

Related Questions