TabWidget自定义背景图片 我给TabWidget自定义了背景图片,为什么图片四周都有空,不能紧靠边缘?如图:第一个标签我没添加图片,第二个添加的是系统自带的图片,第三个是我自己做的图片,为什么第三个图片四周有空隙? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是为什么呀,怎么都搞不定了刚刚新建了一个测试用的工程,什么东西都没加,也是不行,图片大小:200*100下面是我的main.xml,谁能帮我看看有问题没,要怎么修改。<TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" 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_marginTop="0dp" android:paddingTop="0dp" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout></TabHost> 我按照楼主的方法也试了下,发现真有空白的地方,期待高手解决!不过这个需求应该不怎么重要吧,或者不用tabhost做,直接用三个button放上面,然后动态改变下面部分的布局应该可以吧! android:layout_height="wrap_content"改成android:layout_height="fill_parent"试试毕竟你的图片宽高比是2:1的 <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"/>这样就可以了吧,宽度填充父窗口,高度自适应。建议LZ把图片做成9.png再试试。系统会自动拉伸的。 是文件名为xxx.9.png吗?这样的话eclipse报错,在文件夹上有红叉 tabwidget可以自己实现现实的view而不用自带的那个,setIndicator有一个重载参数是View的 for (int i = 0; i < tabHost.getChildCount(); i++) { tabWidget.getChildAt(i).setBackgroundResource(R.drawable.bg_tab); }楼主 试试这样? 最后一问,什么叫把图片做成9.png,我把图片命名为XXX.9.png,eclipse文件夹红叉,运行报错,能不能再说两句 view.setBackgroundDrawable(),用这个方法就可以啦,android可以把图片拉伸 网上找下,9.png的图片做起来很简单的 lz 我今天也遇到这个问题了你的图像尺寸 不符合 TAB的比例按照320x480的分辨率一共4个TAB 那个每个 320/4 = 80高度你如果自适应的话, 那么如果 height:80 != 你的图像的 weight/height那么就会出现你所说的情况修改一下图像尺寸 应该就没问题了 你试试 aaa×aaa 的图片 就是正方形的图 图片加载的地方加个:android:scaleType="center" eclispe 安装arcgis for android 插件 很诡异 android手机的sd卡 jdk 安装不成功 求解 android 4.3 BLE 经常性的发现不了服务 可拓展listview 对百度地图开发有经验的朋友求帮忙,昨天地图还可以显示,今天就只能显示网格了,求助 progurad 之后报错误 AIDL中访问网络资源问题 怎么识别手机的IMEI是否被刷过的?【贡献一半身家分数求方案】 Androidstudio 为什么只能创建java程序了 android手机铃声问题? ubuntu下编译android源码报错
刚刚新建了一个测试用的工程,什么东西都没加,也是不行,图片大小:200*100
下面是我的main.xml,谁能帮我看看有问题没,要怎么修改。
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
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_marginTop="0dp" android:paddingTop="0dp" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
</LinearLayout></TabHost>
我按照楼主的方法也试了下,发现真有空白的地方,期待高手解决!
不过这个需求应该不怎么重要吧,或者不用tabhost做,直接用三个button放上面,然后动态改变下面部分的布局应该可以吧!
改成
android:layout_height="fill_parent"
试试
毕竟你的图片宽高比是2:1的
android:layout_width="fill_parent" android:layout_height="wrap_content"/>这样就可以了吧,宽度填充父窗口,高度自适应。建议LZ把图片做成9.png再试试。系统会自动拉伸的。
}
楼主 试试这样?
最后一问,什么叫把图片做成9.png,我把图片命名为XXX.9.png,eclipse文件夹红叉,运行报错,能不能再说两句
按照320x480的分辨率
一共4个TAB 那个每个 320/4 = 80高度你如果自适应的话, 那么如果 height:80 != 你的图像的 weight/height那么就会出现你所说的情况修改一下图像尺寸 应该就没问题了