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 6069953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:52:43+00:00 2026-05-23T09:52:43+00:00

I’m having a problem with layer-list on Android. I want to do a simple

  • 0

I’m having a problem with layer-list on Android. I want to do a simple pile of images. I can achieve that with the following code:

<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <rotate 
        android:pivotX="50%" android:pivotY="50%"
        android:fromDegrees="0" android:toDegrees="0">
        <bitmap
            android:src="@drawable/teste1"
            android:gravity="center" />
    </rotate>
</item>

<item>
    <rotate 
        android:pivotX="50%" android:pivotY="50%"
        android:fromDegrees="-9" android:toDegrees="-9">
        <bitmap
            android:src="@drawable/teste3"
            android:gravity="center" />
    </rotate>
</item>

<item>
    <rotate 
        android:pivotX="50%" android:pivotY="50%"
        android:fromDegrees="9" android:toDegrees="9">
        <bitmap
            android:src="@drawable/teste2"
            android:gravity="center" />
    </rotate>
</item>

</layer-list>

But when I run it, the result is cropped on the top and on the bottom, as seen on the following image:

cropped_image

I have another doubt: if I put an ID on the <item> how do I retrieve it on my View so I can change the bitmap in code? The documentation* says I have to use an View.findViewByID, but I want to get the BitmapDrawable, and I can’t cast a View to a Drawable!

I also tried coding the same thing on a CustomView, with Canvas.drawBitmap, but it’s looking very ugly, if someone can point out a good solution using that I would appreciate too.

Thanks in advance

  • 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-23T09:52:44+00:00Added an answer on May 23, 2026 at 9:52 am

    What are you putting that layer list in? What’s the XML that uses it as a drawable? Have you tried adding some top and bottom padding to the view that contains your layer drawable?


    As for accessing the bitmap from code, you need to get the LayerDrawable first, then use its getDrawable or findDrawableByLayerId methods.

    For example, if you’re using a layer of bitmap items as the background of a view whose id is ‘container’ you could do this:

    // get the layer list being used as the background of 'container'
    View view = findViewById(R.id.container);
    LayerDrawable layer = (LayerDrawable)view.getBackground();
    
    // get the first layer's BitmapDrawable by index
    BitmapDrawable bg = (BitmapDrawable)layer.getDrawable(0);
    
    // get the BitmapDrawable of the layer whose id is 'teste2'
    BitmapDrawable bgTeste2 = (BitmapDrawable)layer.findDrawableByLayerId(R.id.teste2);
    
    // do whatever you want with the drawable
    bg.setAlpha(60);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace

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.