2012-01-27 191 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