I suspect your penguin image is too large.


I see that the penguin image comes with Windows and is 1024x768.  Perhaps 
the problem relates to the downscaling of this image?  Why not try a 
smaller image that requires no scaling?




On Monday, September 17, 2012 10:08:33 PM UTC-5, yu wrote:
>
> Even if I change the layout as below to avoid the loop, what I get is 
> still is that "the bitmap looks quite different with the view"
>
> <?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">
>     <Button android:layout_width="match_parent"
>         android:layout_height="*wrap_content*"
>         android:text="Test"
>         android:id="@+id/btnTest"/>
>     <ImageView android:layout_width="match_parent"
>         android:layout_height="*match_parent*"
>         android:id="@+id/ivTest"/>
> </LinearLayout>
>
> Is there any method to resolve this problem? Thanks a lot.
>
> 2012/9/18 bob <b...@coolfone.comze.com <javascript:>>
>
>> I don't think your layout code makes sense, particularly the height 
>> specification.
>>
>> You have this for the LinearLayout:
>>
>>  android:layout_height="wrap_content"
>>
>> This says '*Look at my children to figure out the height*'.
>>
>> Then you have this for the ImageView:
>>
>>    android:layout_height="match_parent"
>>
>> This says *'Look at my parent (aka LinearLayout) to figure out the height
>> *'.
>>
>> It is like the parent is saying 'go talk to the child' and the child is 
>> saying 'go talk to the parent' in an endless loop.
>>
>>
>>
>>
>> On Monday, September 17, 2012 9:46:57 AM UTC-5, yu wrote:
>>>
>>> Hi all,
>>>
>>> I use below codes to generate the bitmap of a view:
>>>
>>>         view.measure(MeasureSpec.**makeMeasureSpec(0, 
>>> MeasureSpec.UNSPECIFIED),
>>>                 MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
>>>         view.layout(0, 0, view.getMeasuredWidth(), 
>>> view.getMeasuredHeight());
>>>         Bitmap bitmap = Bitmap.createBitmap(view.**getWidth(), 
>>> view.getHeight(),
>>>                 Bitmap.Config.ARGB_8888);
>>>         final Canvas canvas = new Canvas(bitmap);
>>>         view.draw(canvas);
>>>
>>> However, when the view really displays, it looks quite different with 
>>> the bitmap that I get. Please see below two snapshots.
>>> *Below is the bitmap that I generated:*
>>>
>>>
>>> <https://lh5.googleusercontent.com/-7tOJkO961Es/UFc3XjIvrFI/AAAAAAAAAGU/vXNeEPF-xyY/s1600/bitmap.png>
>>>
>>>
>>> *Below is the view's real display:*
>>>
>>>
>>> <https://lh5.googleusercontent.com/-x76-haIiBOI/UFc3gTBYTnI/AAAAAAAAAGc/b5dkPTrLlNk/s1600/view.png>
>>>
>>>
>>> *Below is the layout of this view:*
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <LinearLayout xmlns:android="http://schemas.**
>>> android.com/apk/res/android <http://schemas.android.com/apk/res/android>
>>> "
>>>     android:layout_width="wrap_**content"
>>>     android:layout_height="wrap_**content"
>>>     android:orientation="vertical"**>
>>>     <Button android:layout_width="match_**parent"
>>>         android:layout_height="wrap_**content"
>>>         android:text="Test"
>>>         android:id="@+id/btnTest"/>
>>>     <ImageView android:layout_width="match_**parent"
>>>         android:layout_height="match_**parent"
>>>         android:id="@+id/ivTest"/>
>>> </LinearLayout>
>>>
>>> However, the above method is searched and got from stackoverflow. So I 
>>> assume it should work. Can someone tell me why the bitmap that I get is 
>>> different with the real display and how to resolve it? Thanks in advance.
>>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to 
>> android-d...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>

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

Reply via email to