简体   繁体   中英

Android, How to stick gallery into left side of screen?

I have two questions.

The first, when i load the activity first item of gallery is in the middle. How to ask android to align it to left? (actually i used align="left" but it seems doesn't work)

the second, my activity includes three items, header, body and footer. currently the footer (gallery) is on top of body. I want bottom of body stays on above of footer instead of behind of footer.

any suggestions appreciated. The image is like this.

在此处输入图片说明

the code:

<?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"
    android:background    = "@drawable/bg" >


    <!-- Loading header of this UI which is coded separately -->
    <include
        android:id="@+id/header" 
        layout="@layout/header_bar" />



    <GridView 
        android:id="@+id/news_gridview"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:numColumns="2"
        android:verticalSpacing="5dp"
        android:horizontalSpacing="5dp"
        android:layout_below="@id/header"
        android:layout_centerInParent="true" />  


    <Gallery 
        android:id="@+id/gallery"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />

</RelativeLayout>

For 1st:

Check this existing SO question:

For 2nd: - You need to include android:layout_above="@+id/gallery" in your GridView. - Remoev android:layout_centerInParent="true"

In short, define:

<GridView 
        android:id="@+id/news_gridview"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:layout_marginTop="10dip"
        android:numColumns="2"
        android:verticalSpacing="5dp"
        android:horizontalSpacing="5dp"
        android:layout_below="@+id/header"
        android:layout_above="@+id/gallery"/>  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM