Android的径向渐变 [英] Android radial gradient

查看:1007
本文介绍了Android的径向渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面绘制一组为LinearLayout中的背景我有:

I've got following drawable set as LinearLayout background:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
      <bitmap
         android:tileMode="repeat"
         android:dither="true"
         android:src="@drawable/bg"/>
   </item>


   <item>
      <shape android:shape="rectangle">
         <gradient
            android:startColor="#ffff0000"
            android:endColor="#ff00ff00"
            android:centerX="50%"
            android:centerY="50%"
            android:gradientRadius="50%"
            android:type="radial"/>
      </shape>
   </item>
</layer-list>

根据<一href="http://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html#attr_android%3agradientRadius"相对=nofollow>文档,gradientRadius可设定的窗口/父大小百分比。 Unfortunetely ......它不工作。在半径为0。我究竟做错了什么?或者,有什么不对的Andr​​oid?

According to the docs, gradientRadius can be set to percentage of window/parent size. Unfortunetely... it's not working. The radius is 0. What am I doing wrong? Or what's wrong with Android?

我需要的径向渐变填充整个屏幕。有什么解决办法?

I need the radial gradient to fill the whole screen. What's the workaround?

推荐答案

如果我非常理解你需要什么,你必须进行布局其中referded通过绘制

if i understand well what you need you have to make layout which referded by drawable

(match_parent),

( "match_parent" ) ,

如下:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:background="@drawable/"your drawable xml name">

希望这种帮助。

hope this help .

这篇关于Android的径向渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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