2012-04-08 47 views
1

我想將這個gridview對齊,以便它與屏幕右側齊平,但似乎總是立即跟隨我將其設置在右側的任何textview。不僅如此,而且所有的文本瀏覽都是相互顯示的。不符合Relativelayout對齊的GridView

<?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:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="@string/time_left" 
       android:textSize="30sp" 
       android:layout_alignParentLeft="true" 
       android:id="@+id/time_left_label"/> 
    <TextView android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:id="@+id/time_left" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@id/time_left_label"/> 
    <TextView android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="@string/progress" 
       android:textSize="30sp" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@id/time_left" 
       android:id="@+id/progress_label" /> 
    <TextView android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:id="@+id/progress" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@id/progress_label"/> 
    <GridView android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:id="@+id/main_grid" 
       android:numColumns="2" 
       android:layout_alignParentRight="true" 
       android:layout_toRightOf="@id/time_left_label" 
       android:stretchMode="none" /> 
</RelativeLayout> 

下面是我想快速繪製的圖片! http://imgur.com/x7Ypr

+0

1.文字瀏覽在彼此之上,因爲它們都是左對齊的。使用android:layout_toRightOf =「」,它們不會重疊。如果 可以啓動繪畫並繪製所需佈局的圖片,我們可能會更輕鬆地幫助您。 – Renard 2012-04-08 19:40:27

回答

1

我想右對齊這個gridview的

你想如何準確對準它?你提到它的作用,但不是你想要的。

似乎......跟隨爲準的TextView我將它設置爲

Welll正確的,你使用layout_alignParentRightlayout_toRightOf

textviews顯示在彼此的頂部。

將您的TextViews放在彼此下面不會堆疊它們。您可以使用LinearLayout,其orientation設置爲vertical,或者您可以使用layout_below將它們置於彼此之下。

+0

我已做出更改以使文本不重疊。謝謝,我現在感到很傻,因爲沒有想到這一點。 – worr 2012-04-08 22:08:01