我试图用一个背景(分辨率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>

background.xml在res /抽拉

<?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的内部元件可重叠,这现在应该工作,并且在布局使用可绘制独立地,而不是包含作为元件background_src一个位图可能给你更多的灵活性。

其他提示

背景设置为UR tabhost标签不tabcontent布局。即

<TabHost android:background="@drawable/background">
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top