Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:21:51+00:00 2026-05-28T08:21:51+00:00

I am having trouble using a Drawable with ShaderFactory in a LayerDrawable. It is

  • 0

I am having trouble using a Drawable with ShaderFactory in a LayerDrawable. It is showing all black instead of to the two layers (none of which should be all black). It worked when I used a static Shader using drawable.getPaint().setShader(), but not now with ShaderFactory.

ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() {
    @Override
    public Shader resize(int width, int height) {
        Log.d("shader", width+"x"+height);
        LinearGradient gradient = new LinearGradient(0, 0, width, height, 
            new int[] { 0x33FF0000, 0x00000000, 0x00000000, 0x11000000 }, 
            new float[] { 0.0f, 0.04f, 0.97f, 1.0f }, Shader.TileMode.CLAMP);
        return gradient;
    }
};
ShapeDrawable grad = new ShapeDrawable();
grad.setShaderFactory(sf);
Drawable[] layers = new Drawable[] { anotherDrawable, grad };
Drawable d = new LayerDrawable(layers);
someImageView.setImageDrawable(d);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:21:51+00:00Added an answer on May 28, 2026 at 8:21 am

    It turns out the problem was that I did not specify the shape of the ShapeDrawable.

    ShapeDrawable grad = new ShapeDrawable(new RectShape());
    

    Changed to this and it is now good. Another thing was that I actually wanted to specify the linear gradient from top to bottom so I don’t need the width, and the effect makes me didn’t notice it. So in fact the drawing it with PaintDrawable also works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble using the attribute XPath Selector in ElementTree, which I should
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
I'm having trouble using db.ReferenceProperty with PolyModel in GAE. If I have two models
Im having trouble using a .NET COM in vb6, It compiles ok and I
I am using mssql and am having trouble using a subquery. The real query
I'm having trouble using the flowlayoutPanel in a C# winform application. What I basically
I've been having trouble using cucumber and webrat to test authlogic-openid authentication in a
I'm having trouble using os.utime to correctly set the modification time on the mac
I am having trouble using EnumSet on the client side. I get this runtime
I'm new to development using Xcode, and am having trouble using the built-in Leaks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.