W dniu niedziela, 27 stycznia 2013 04:04:22 UTC+1 użytkownik Justin Buser 
napisał:

> I did actually, not that it's really relevant. I also looked back through 
> the aosp commit logs and found a grand total of 1 commit that he made, but 
> that's not really relevant either as it doesn't really PROVE anything... My 
> frustration was based on the fact that I was looking for a solution to a 
> problem, and found almost exactly the same couple of paragraphs that he 
> posted here in several other places as well, all of which were pertaining 
> to different problems, and none of those problems were related to the 
> information he was providing. 
>

You probably wouldn't sound like total (frustrated) douchebag if you know 
what you are saying. Romain advice was of course correct, and your comment 
about forceLayout() just proves you have no idea what you are talking about.

Layout is normally done in layout pass, before drawing, and (because layout 
is time consuming) it only perform when needed (that is when view is marked 
as being eligible for layout). So requestLayout and forceLayout just marks 
view to execute layout pass (and indeed will never be executed if view is 
not inside view hierarchy) but Romain never suggested to call forceLayout.
His advice was to call layout directly and  doing that will execute layout 
- that is will calculate position and size of view and will setup drawing 
cache bitmap if enabled. 
Everything I just wrote you could easily find in sources, but you are not 
up to that task (Android sources could be sometimes hard to read), you 
could make a simple test:

package com.test.layout;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        ImageView v1 = new ImageView(this);
        
v1.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher));
        v1.setDrawingCacheEnabled(true);
        Bitmap b1 = v1.getDrawingCache();
        
        ImageView v2 = new ImageView(this);
        
v2.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher));
        v2.setDrawingCacheEnabled(true);
        v2.layout(0, 0, 200, 200);
        Bitmap b2 = v2.getDrawingCache();
        
        if (null != b1) {
            ((ImageView) findViewById(R.id.imageView1)).setImageBitmap(b1);
        } else {
            Log.d("TEST", "Cannot get bitmap1");
        }
        if (null != b2) {
            ((ImageView) findViewById(R.id.imageView2)).setImageBitmap(b2);
            Log.d("TEST", "Wow it works, it's probably a miracle");         
   
        } else {
            Log.d("TEST", "Cannot get bitmap2");
        }
    }
}

which would take like 15 minutes and prove that you assertion were 
baseless, but instead you choose to spend 20 minutes on writing stupid 
and arrogant accusations, that's also an option I guess.

--
Bart

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Reply via email to