问题描述
<TabHost
android:id="@+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
// --------------------------- Here I got warning -------------------------
<LinearLayout
android:id="@+id/chat_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible" >
// --------------------------------------------------------------------------
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white" >
</ListView>
<LinearLayout
android:id="@+id/text_entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal" >
<EditText
android:id="@+id/txt_inputText"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:hint="@string/enter_text"
android:inputType="text" />
<Button
android:id="@+id/btn_Send"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="@string/send" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" >
</TabWidget>
</LinearLayout>
</TabHost>
如何解决这个警告呢?我找不到任何解决方案。任何帮助将AP preciated。
How to solve this warning ? I can't find any solution. Any help will be appreciated.
推荐答案
我不知道你要完成什么,但你可以通过移动的FrameLayout $ C摆脱警告$ C>内容到一个单独的文件,并使用其重新添加到您的
TabHost
&LT;包括方式&gt;
标记
I am not sure what exactly you are trying to accomplish, but you can get rid of the warning by moving FrameLayout
content to a separate file and add it back to your TabHost
by using <include>
tag.
一个可能的版本可能看起来是这样的:
A possible version could look something like this:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<include layout="@layout/tab_chat_list" />
</FrameLayout>
</LinearLayout>
</TabHost>
和tab_chat_list.xml:
And tab_chat_list.xml:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/chat_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible" >
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white" >
</ListView>
<LinearLayout
android:id="@+id/text_entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal" >
<EditText
android:id="@+id/txt_inputText"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:hint="@string/enter_text"
android:inputType="text" />
<Button
android:id="@+id/btn_Send"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="@string/send" />
</LinearLayout>
</LinearLayout>
</merge>
希望这有助于。
更新
的我注意到,有些人建议删除的FrameLayout
。虽然,在其他情况下,可能已经解决了这个问题, TabHost
需要 TabWidget
和的FrameLayout
正常工作。的
I noticed that some people are suggesting to remove FrameLayout
. Although, that could have solved the problem in other cases, TabHost
needs TabWidget
and FrameLayout
to function correctly.
这篇关于得到了警告:此布局的LinearLayout或其母公司的FrameLayout可能是没用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!