Search code examples
androidandroid-gallery

Gallery View to move beyond the background of parent


I am working with gallery. My layout for the same is:

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

<TextView
    android:id="@+id/mySelection"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ff0000ff"
    android:textSize="20px"
    android:textStyle="bold" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:background="#fff785" >

    <Gallery
        android:id="@+id/myGallery"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

        android:spacing="10dp" />
</LinearLayout>

</LinearLayout>

In this what happens is obtained gallery

But I want it like gallery view should move beyond the background like facebook. This is the image what i want it to be expected

Please suggest what modification can I do to achieve it.


Solution

  • I found the answer for the question which I asked above . I made parent layout as Relative and in that I added Linear Layout with background of what I want. With this i placed Gallery above Linear Layout. And I am able to get what I want to acheive.

    layout file:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     >
    
    <TextView
        android:id="@+id/mySelection"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ff0000ff"
        android:textSize="20sp"
        android:textStyle="bold" />
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="10dp"
        android:background="#fff785"
        android:layout_below="@+id/mySelection" >
    
    
    </LinearLayout>
    
    <Gallery
            android:id="@+id/myGallery"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:overScrollMode="always"
            android:spacing="10dp" />
    </RelativeLayout>