[英]Background in tab widget ignore scaling
我试图将背景(480x320)用于标签内容。 使用xml作为可绘制对象,我应该能够缩放图像。 在tabhost / tabactivity之外可以正常工作。 如果尝试在tabcontent内使用它,则scaleType不起作用。 他忽略了我尝试过的每个scaleType。
tabcontent:
<?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"
android:background="@drawable/background">
<include layout="@layout/main_list" />
</RelativeLayout>
res / drawable中的background.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/background_img"
android:scaleType="centerInside"/>
当然,我通过更改图像来检查是否确实使用了xml,在更改图像时使用了xml。
使用的缩放比例似乎是fitXY,因为整个背景都是可见的,但宽高比却被忽略了。
有什么想法吗?
尝试仅将其放置在RelativeLayout中,而不使用背景可绘制对象:
<Drawable
android:src="@drawable/background_img"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:scaleType="fitCenter" />
由于relativelayout内的元素可以重叠,因此这应该可行,并且在布局中独立使用Drawable而不是作为background_src元素包含的位图可以为您提供更大的灵活性。
将背景设置为不在tabcontent布局中的ur tabhost标记。 那是
<TabHost android:background="@drawable/background">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.