背景在标签控件忽略缩放 [英] Background in tab widget ignore scaling

查看:100
本文介绍了背景在标签控件忽略缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个背景(小480x320)我的选项卡的内容。使用XML作为绘制,我应该能够缩放图像。这将tabhost / tabactivity外面工作正常。如果我尝试使用它的tabcontent里面,scaleType不起作用。他忽略每个scaleType我试过了。

I tried to use a background (480x320) for my tab content. Using a xml as drawable, I should be able to scale the image. This works fine outside the tabhost/tabactivity. If I try to use it inside the tabcontent, the scaleType doesn't work. He ignores every scaleType I tried.

tabcontent:

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 /绘制

background.xml in res/drawable

<?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。

Of couse I checked if the xml is really used by changing the image, at the image changed so the xml is used.

所使用的比例似乎是fitXY,因为整个背景是可见的,但宽高比会被忽略。

The used scaling seems to be fitXY, because the whole background is visible but the aspect ration is ignored.

一些想法?

推荐答案

尽量只把这个RelativeLayout的内部,而不是用你的背景绘制:

Try just placing this inside the RelativeLayout and not using your background drawable:

<Drawable 
    android:src="@drawable/background_img" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:scaleType="fitCenter" />

由于RelativeLayout的内部元件可以重叠,这个现在应该工作,并利用布局中绘制对象而不是独立的位图包含的元素background_src可能给你更多的灵活性。

Since elements inside the relativelayout can overlap, this oughta work, and using a Drawable in the layout independently instead of a Bitmap included as the element background_src might give you more flexibility.

这篇关于背景在标签控件忽略缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆