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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:24:21+00:00 2026-06-13T23:24:21+00:00

I have a problem when I take a snapshot of my screen. The bitmap

  • 0

I have a problem when I take a snapshot of my screen. The bitmap paint everything but the bottom of the view. I attach some code of the layout and also from the snapshot call.

The activity has also an action bar with TabListeners. So it has 3 tabs and few buttons in the action bar (they are shown on the snapshot. Could be nice if I could delete them as well in the snapshot causes I don’t need them at all ^^U But it is not the important thing).

Snapshot:

    private void snapShot() {
        Log.d("On snapShot","At beggining");
        Bitmap bitmap;
        getWindow().getDecorView().setDrawingCacheEnabled(true);    
        try{
            bitmap = Bitmap.createBitmap(getWindow().getDecorView().getDrawingCache());
        }catch (IllegalStateException e){
            bitmap = null;
        }
        try{    
            Log.d("On snapShot", "inside Try");
            File root = Environment.getExternalStorageDirectory();              
            if (root.canWrite()){
                pic = new File(root,"pic.png");
                FileOutputStream out = new FileOutputStream(pic); 
                bitmap.compress(CompressFormat.PNG, 100, out); 
                out.flush(); 
                out.close();
            }
        }catch(IOException e) { 
            Log.e("BROKEN", "Could not write file " + e.getMessage());
        }
        getWindow().getDecorView().setDrawingCacheEnabled(false);       
     }

Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout 
        android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="horizontal" 
  android:layout_weight="20"
  >
  <com.example.daemon.views.CaptionView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id = "@+id/legendView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
  </com.example.daemon.views.CaptionView>

        <View 
            android:id="@+id/lineSeparation"
            android:background="#F000"
            android:layout_marginTop="1dp"
            android:layout_height="1dp"
            android:layout_width="match_parent"
         /> 
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <com.example.daemon.views.ChartView
      xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/viewChart"
          android:layout_width="fill_parent"
      android:layout_height="fill_parent">
  </com.example.daemon.views.ChartView>
    </LinearLayout>
</LinearLayout>

Add a little more code, where the action bar and the tabs are created.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);    // Set the application works only on Landscape orientation.
    actionBar = getActionBar();                                     // Creates the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);                
    Log.i(TAG, "On create");
    String label1 = "one day";              
    Tab tab = actionBar.newTab();           // Creates a tab
    tab.setText(label1);                

    // Links the tab created with an existing Fragment 
    TabListener<Tab1Fragment> tl = new TabListener<Tab1Fragment>(this, label1, Tab1Fragment.class);     
    tab.setTabListener(tl);                 // Makes the tab  respond the touch events.
    actionBar.addTab(tab);                  // Add the tab to the action bar.

PNG when i push the snapshot:
enter image description here

How it should appear, picture from my camera:
enter image description here

The problem (I think) is that when the bitmap is created its maximun height is 732 (the same than the view) but it start capturing the view from the top (including the action bar that is not on the view) so it only can paint the first 732 rows. The point is that if I said to start after the action bar, an error appear because “y + height cannot be > bitmap.height” so… what can I do?

Thank you a lot!!!

  • 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-06-13T23:24:23+00:00Added an answer on June 13, 2026 at 11:24 pm

    I found the solution.
    It was hard to find it but it’s quite easy.
    I just add to the first LinearLayout (the one which content all the others) an id.
    Then I can create the bitmap finding the view by id.

    In the layout I add: android:id="@+id/mainLayout"
    and then in the activity:

    int id = R.id.mainLayout;
    View view = findViewById(id);                   
    view.setDrawingCacheEnabled(true);
    Bitmap bitmap = Bitmap.createBitmap(getWindow().findViewById(id).getDrawingCache());    
    

    Thanks for the support and I hope this will help to someone else.

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

Sidebar

Related Questions

Okay so i have a semi weridish problem with re.sub. Take the following code:
I have problem with python multithreaded Queues. I have this script, where producer take
I have a problem with li , when I take li in inline display
This is my first post here. I have a problem. I need to take
I am struggling with a problem in assembly, where I have to take the
i have following problem To decode the Biquinary code use the number 5043210. At
I have problem with building in Qt4 creator. I have some created projects and
I have a problem with sitemap listing. please take a look at this. sitemap
I have a problem on taking the snapshot of html document running on different
I have problem with latin chars, here is the code: $stopWords = array('i','a','about','an','and','are','as','at','be','by','com','de','en','for','from','how','in','is','it','la','of','on','or','that','the','this','to','was','what','when','where','who','will','with','und','the','www', 'on',

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.