能否绘制形状有它的大小设置为FILL_PARENT? [英] Can a drawable shape have it's size set to fill_parent?

查看:132
本文介绍了能否绘制形状有它的大小设置为FILL_PARENT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它是有效的形状绘制在Android中使用 FILL_PARENT 为它的大小?

Is it valid for a drawable shape in Android to use fill_parent for it's size?

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

<solid
        android:color="#666666"/>

<size
        android:width="fill_parent"
        android:height="fill_parent"/>
</shape>

修改

这对的ImageButton 意见的背景。我想要的按钮有一个背后的圆形图标,但我并不总是知道什么按钮的大小将是(每版面大小不同)。

This for the background of ImageButton views. I want the icon for the button to have a circle behind it, but I don't always know what the size of the button will be (different sizes per layout).

推荐答案

不是真的。不使用 ShapeDrawable 孤单。如果你通过了 ShapeDrawable 的文件,你会看到(的您已经使用他们的标签的),唯一有效的属性有<强> PX DP SP 毫米

Not really. Not using a ShapeDrawable alone. If you go through the ShapeDrawable document, you will see (you are already using them in the tag) that the only valid attributes there are px, dp, sp, in and mm

从DOC引述:<一href="http://developer.android.com/reference/android/graphics/drawable/ShapeDrawable.html#attr_android%3awidth"><$c$c>android:width="...."

A quote from the doc: android:width="...."

可用的单位有:PX(像素),DP(密度无关的像素),SP   (基于$ P $缩放像素pferred字体大小),在(英寸),毫米   (毫米)    这是真正的属性:<一href="http://developer.android.com/reference/android/graphics/drawable/ShapeDrawable.html#attr_android%3aheight"><$c$c>android:height

Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters) This is true for the attribute: android:height

这是炒作对我而言的,但我怀疑为什么FILL_PARENT属性值将无法正常工作是因为 ShapeDrawble ,不像一个 XML布局文件将不会有一个父容器。

This is speculation on my part, but I suspect why the fill_parent attribute value will not work is because a ShapeDrawble, unlike an XML Layout file will not have a parent container.

离开了&LT;大小... /&GT; 属性完全和设置 layout_width layout_height 上的小工具,将引用该ShapeDrawable是唯一的选择,我怀疑(如果的 FILL_PARENT 是要兑现)。

Leaving out the <size.... /> attribute entirely and setting the layout_width and layout_height on a Widget that will reference the said ShapeDrawable is the only option I suspect (if the fill_parent is to be honored).

这篇关于能否绘制形状有它的大小设置为FILL_PARENT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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