2012-03-09 101 views
0

我有两个问题。Android,如何将画廊粘贴到屏幕的左侧?

第一,当我加载活动的第一件画廊是在中间。如何让android将它对齐到左边? (实际上我使用align =“left”,但它似乎不起作用)

第二,我的活动包括三个项目,标题,正文和页脚。目前页脚(画廊)位于身体之上。我希望身体的底部停留在页脚上方而不是页脚后面。

任何建议表示赞赏。图像是这样的。

enter image description here

代码:

<?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> 

回答

3

为1:

检查这个现有的SO问题:

For 2nd: - 您需要在您的GridView中包含android:layout_above="@+id/gallery"。 - Remoev android:layout_centerInParent="true"

总之,定义:

<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"/> 
+0

谢谢帕雷什。而不是使用如此多的代码行我喜欢使用“gallery.setSelection(imAdapter.getCount()/ 2);”将画廊带到中间。但我提出了第二条建议的建议,但发生了错误,我不知道为什么,但我无法使用它。再次感谢。 – Hesam 2012-03-09 06:17:17

相关问题