2016-10-03 65 views
0

我有gidLayout的問題。我有這個網格:網格佈局要素髮行

enter image description here

這是它的外觀在Android Studio中。但是當我在平板電腦上安裝應用程序時,所有元素都看起來很糟糕。

所有元素都正確放置在他的行和列,但其 背景不碰。像layout_columnWeight和layout_rowWeight沒有作品.. 見200ºC文本元素:

enter image description here

網絡佈局的代碼和XML的所有元素:

<GridLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:columnCount="12" 
      android:rowCount="12" 
      android:background="@color/black" 
      android:layout_weight="1" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentStart="true"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="Barra notificacions" 
       android:id="@+id/textView" 
       android:layout_row="0" 
       android:layout_column="0" 
       android:layout_rowWeight="1" 
       android:layout_columnWeight="1" 
       android:gravity="center_vertical|center_horizontal" 
       android:background="@color/fondoGrid" 
       android:layout_margin="1dp" 

       android:layout_gravity="fill_horizontal" 
       android:layout_columnSpan="7" /> 
...other textViews 
+0

你試過' kujeensiti

+0

是的,但在這種情況下,所有的元素具有與屏幕的。 – WIngenia

回答

0

您需要設置layout_width=wrap_content在網格佈局上。這應該解決這個問題。 我有類似的問題;然而,我的網格佈局載的幀結構內,所以我不得不設置寬度爲wrap_content兩個。