2012-01-27 175 views
0

我想在以下圖像中放置TextViewbelow the red zone,但我只能這樣做。 enter image description http://i43.tinypic.com/cm93s.png在屏幕上顯示textView

到現在爲止,我有以下佈局:

<TabHost android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@+id/tabhost1" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 

<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 

<TabWidget 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:id="@android:id/tabs" 
android:layout_alignParentBottom="true" 
/> 

<FrameLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@android:id/tabcontent" 
> 
</FrameLayout> 
</RelativeLayout> 
</TabHost> 

<LinearLayout android:layout_width="fill_parent" 
android:layout_below="@id/layout" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/text" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="0 restaurant trouves" 
android:gravity="center_horizontal" 
android:layout_alignParentBottom="true" 
android:textSize="15dip" 
android:textColor="#000000" 
/>  
</LinearLayout> 

有人可以告訴什麼是正確的代碼將textView放置在紅色標籤下面嗎? 謝謝!

回答

0

是您在一篇XML文件中的帖子中提到的所有內容嗎?它看起來沒有很好的格式化,你的截圖也沒有說清楚,但我試了一下。

看來你的TextView甚至不在RelativeLayout內。你在聲明你的TextView之前關閉它的標籤,所以你必須將它移動到RelativeLayout中。 而且我不知道是否要在每個Tab中顯示此TextView。但是如果是這樣的話,你可以嘗試下面的方案:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <LinearLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" > 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 
      </TabWidget> 

      <RelativeLayout 
       android:id="@+id/relativeLayout1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:text="TextView" /> 

       <TextView 
        android:id="@+id/textView2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/textView1" 
        android:text="TextView" /> 
      </RelativeLayout> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <LinearLayout 
        android:id="@+id/tab1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 

       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/tab2" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 
       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/tab3" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 
       </LinearLayout> 
      </FrameLayout> 

     </LinearLayout> 
    </TabHost> 

</LinearLayout> 

這個例子中有兩個TextViews。一個被居中,另一個被繪製在第一個下方:android:layout_below="@id/textView1"

現在你有你的看法做到這一點...

+0

我真的不知道你有什麼那裏進行,但沒有,它不是working.Let我說清楚:我在下面的空格兩個選項卡(清單當然和計劃)他們我想把這個textView !!!!!!!! – adrian 2012-01-27 15:37:17

+0

是的,我希望它在Liste和Plan標籤中都可見! – adrian 2012-01-27 15:38:36

0

佈局代碼似乎並沒有讓你對截圖的一切,所以我不知道你的紅組選項卡是如何工作的,但這裏有一個簡單的視圖中的樣機:

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" /> 

    <TextView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@android:id/tabs" 
     android:layout_centerHorizontal="true" 
     android:background="#FFFFFF" 
     android:gravity="center_horizontal" 
     android:text="0 restaurant trouves" 
     android:textColor="#000000" 
     android:textSize="15dip" /> 

    <View 
     android:layout_width="fill_parent" 
     android:layout_height="50dp" 
     android:layout_above="@+id/text" 
     android:background="#ff0000" /> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 
    </FrameLayout> 
</RelativeLayout> 

這將會給你:(日食截圖,在widg沒有標籤等)

enter image description here