2012-05-09 42 views
0

enter image description here 我試圖刪除它在textview之前和之後自動創建的空格。這怎麼可能?xml在textview之前和之後的空格

 <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/ripetisfondo" 
      android:padding="1dp" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:shadowColor="#000000" 
       android:shadowDx="1" 
       android:shadowDy="1" 
       android:shadowRadius="2" 
       android:text="@string/titolo1" 
       android:textColor="#FFFFFF" 
       android:textSize="15dp" 
       android:textStyle="bold" /> 

      <ToggleButton 
       android:id="@+id/toggleButton1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" /> 
     </TableRow> 

截圖取自Eclipse。當我運行該應用時,半切換按鈕消失。

+0

你想要的行爲是什麼? TextView在可用空間內正確居中。 – Moritz

+0

截圖取自Eclipse。當我運行該應用時,半切換按鈕消失。 – Hoconosc

回答

1

更改您的TextView像這樣:

android:layout_width="0dp" 
android:layout_weight="1" 

這將使TextView的擴展以填充可用空間其他一切都奠定了在屏幕上。這應該讓切換獲得所需的空間。

編輯

您可能需要包裝,在一個LinearLayout中,使其工作就像我建議。

+0

它的工作原理,非常感謝! – Hoconosc

+0

很高興我能幫到你!接受它作爲答案? – Barak

+0

我已經完成了。 – Hoconosc

0

刪除android:layout_gravity="center"。爲什麼它居中。

+0

我想集中它。但在切換按鈕之前,它有很多空白區域。 – Hoconosc

0

將XML TextView引力設置爲居中,這就是它處於中心位置的原因。將其設置爲您想要的或將其刪除。

+0

我想集中它。但在切換按鈕之前,它有很多空白區域。 – Hoconosc

相關問題