为什么TextView的背景下改变它的大小? [英] Why does the background of TextView change it's size?

查看:116
本文介绍了为什么TextView的背景下改变它的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把一个背景,一个TextView。我希望背景将调整到我的现有布局的参数,也不会改变我的TextView的大小。所以,如果我有宽度和高度设置为WRAP_CONTENT,我希望背景也包装内容(和比例缩小)。不过没有关系,我所得到的是一个更大的TextView

I put a background to a TextView. I expect the background will adjust to my existing layout parameters and will not change the size of my TextView. So if I have width and height set to wrap_content, I would expect the background also wraps content (and scales down). But no, what I get is a bigger TextView

<TextView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="a"
    android:textColor="#ffffff"
    android:textSize="20sp"
    android:background="@drawable/large_bg"
/>

我收到

...

我如何作出这样的背景也服从WRAP_CONTENT?

How do I make that the background also obeys wrap_content?

我的意思是,这看起来像背景将被视为内容...

I mean, this looks like the background would be treated as content...

推荐答案

这是因为,当我们设置背景比的TextView或任何构件根据该background.Until调整本身,除非我们有没有提到修复高度和宽度[及其可怜的做法]

This is because when we set background than textView or any Widget adjusts itself according to that background.Until and Unless we have not mentioned the Fix Height and Width[Its Poor approach]

这篇关于为什么TextView的背景下改变它的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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