[英]Android TabWidget White Space Issue
我正在使用TabWidget,我在TabActivity和Tabs之间得到一个空白区域。
我不知道如何删除这个空格请任何人帮我解决我应该如何删除它,我的tab_main.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabHost
android:id="@android: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="0dip"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
我试图将TabWidget的背景颜色添加到android:color:transparent但是Activity和Tab之间仍然有相同的空白区域。
我不希望我的Activity和Tabs之间有任何分隔空间(是否可以这样做?)
任何人都可以建议我如何摆脱这个空白区域。
您显示的输出最有可能表示边距/填充错误,而不是布局错误。 您的TabWidget
或FrameLayout
可能会有一个边距被您正在使用的整体主题继承。
最有可能以下将解决问题(请注意额外的边距/填充样式):
<FrameLayout
android:layout_marginBottom="0dip"
android:layout_paddingBottom="0dip"
android:background="@android:color/holo_green_light"
android:id="@android:id/tabcontent"
....
.... />
<TabWidget
android:layout_marginTop="0dip"
android:layout_paddingTop="0dip"
android:background="@android:color/holo_blue_light"
android:id="@android:id/tabs"
....
.... />
你的FrameLayout也可以有任何嵌套的组件,它们有一个边距/填充,反过来可能会导致空白区域。 我已经将android:background
添加到FrameLayout和TabWidget中,只是为了帮助排除故障,如果它们之间有任何空白区域。
你说你已经尝试将TabWidget的背景颜色设置为透明 - 但它没有帮助,因为如果有边距 - 则底层活动的背景颜色在透明区域下方显示为白色。 如果将整体RelativeLayout
的背景颜色设置为蓝色 - 那么你会看到蓝色透过。 因此,修复边距/填充而不是试图隐藏它。
从您的屏幕截图,看起来您正在使用WebView
。 Webview
带有默认margin
和padding
> 0.您可以通过覆盖WebView's
body
标记或使用css
将padding
和margin
设置为零。
有关详细信息,请参阅以下SO问题的答案:
看起来就像你在我的项目中遇到类似的问题,查看这个项目并尝试实现可绘制的xml文件,并为你的TabWidget提供这个项目中给出的特定自定义维度。 它肯定会对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.