在XML定义视图中的Andr​​oid背景设置绘制 [英] Setting drawable defined in XML as view's background in Android

查看:103
本文介绍了在XML定义视图中的Andr​​oid背景设置绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨结果
我试图设置XML定义视图的背景的形状。这是它:

Hi
I'm trying to set a shape defined in XML as view's background. Here's it:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:startColor="#fcfcfc"
    android:endColor="#cfcfcf"
    android:angle="270" />
<padding
    android:left="10dp"
    android:top="10dp"
    android:right="10dp"
    android:bottom="10dp" />
<stroke
    android:width="3dp"
    android:color="#aaaaaa">
</stroke>
<corners
    android:radius="1dp" />
</shape>

虽然我已经在外形上定义的填充,当我将它设置为背景布局形状的边缘完全一致看法的边缘。是否有可能使形状不填整个看法?

Although I've defined padding in the shape when I set it as a background to layout shape's edge completely match view's edge. Is it possible to make shape not to fill entire view?

感谢

推荐答案

也许你可以使用&LT;项目&GT; ,就像这样:

maybe you can use <item> ,like this:

<item android:top="95dp" >
 <shape >
    ....
  </shape>
</item>

这篇关于在XML定义视图中的Andr​​oid背景设置绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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