2013-09-05 29 views
0

我有下面的XML:停止視圖時設備是水平的重疊:機器人

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    android:padding="2.0dip" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

<TextView 
     android:textSize="14.0sp" 
     android:textStyle="bold" 
     android:textColor="#ff449def" 
     android:layout_gravity="top|left|center" 
     android:id="@id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
<TextView 
     android:layout_gravity="left" 
     android:id="@id/eventvenue" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/name" /> 
<TextView 
     android:layout_gravity="bottom|left|center" 
     android:id="@id/datetime" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/eventvenue" /> 
<TextView 
    android:layout_gravity="left" 
    android:id="@+id/datetime2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/datetime" /> 
<ImageView 
     android:layout_gravity="right" 
     android:id="@id/customlistrowlogo" 
     android:padding="5.0dip" 
     android:layout_width="80.0dip" 
     android:layout_height="80.0dip" 
     android:scaleType="fitXY" 
     android:cropToPadding="true" 
     android:layout_alignTop="@id/name" 
     android:layout_alignBottom="@id/datetime2" 
     android:layout_alignParentRight="true" 
     android:contentDescription="logo" /> 

</RelativeLayout> 

當應用程序是在垂直模式中,如果在textviews之一的文本太長則它將包裹到下一行,而不是覆蓋圖像。

但是,當我處於水平模式時,文本不會換行到下一行,而是被圖像覆蓋。

垂直::

---------------------------- 
|     image | 
|text text text tex image | 
|t wraps around tex image | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
---------------------------- 

水平::

--------------------------------------------------------------- 
|                | 
|  text           image  | 
|  text text text text text text text text text teimage  | 
|                | 
|                | 
|                | 
|                | 
|                | 
|                | 
|                | 
|                | 
--------------------------------------------------------------- 

不像在垂直一個在文本下降到下一行的水平模式的文本被隱藏在背後的畫面和犯規去到下一行

+0

你的示例xml並沒有真正顯示任何東西,因爲你的所有控件都有'wrap_content',這導致幾乎看不見。請查看您的示例代碼。 – rekire

+0

@rekire你是什麼意思?不遵循 – cxzp

+0

我無法理解您的問題,因爲您的所有控件的寬度都爲零。 – rekire

回答

1

您可以在layout-land文件夾中爲橫向模式創建單獨的XML文件。無論何時您的配置更改,android都會嘗試重新繪製佈局。最好爲橫向視圖創建佈局。

+0

我不同意你一般我總是儘量避免在輪換時重新啓動,這使得比它幫助更麻煩。有非常舒適的情況下,排尿布局是有意義的恕我直言。 – rekire