[Android-Eclair] Miscellaneous tips.

* We can use ‘View.draw(Canvas cavans)’ to draw the view on selected canvas manually. But, as documented, the view must do a full layout. See following example.

— It doesn’t work —
TextView tv = new TextView(this);
tv.setLayoutParams(new LayoutParams(400, 400));

— It works —
TextView tv = new TextView(this);
tv.layout(0, 0, 400, 400);

‘setLayoutParams’ is not doing layout, but just setting parameters for layout. So, we should manually do layout – ex, calling ‘layout’ function. And then we can draw the view.

* In general, view’s coordinate domain is user content area – excluding status bar area. But, in case of Popup, it includes status bar. For example, base origin of left and top value of function ‘popup.showAtLocation(parent, NO_GRAVITY, left, top)’ is top-left of LCD screen – Not user content area. So, popup shown by ‘popup.showAtLocation(parent, NO_GRAVITY, 0, 0)’ is partially covered by status bar.

* ‘android:layout_weight’ is only valid in LinearyLayout – It is natural.

* When array is passed from Java to native code, there are two opions – copy or not. If array size is small, this doesn’t matter. But, in case of large array, this can be important. In Android-Eclair, array is never copied. So, developer don’t worry about passing large-size-array to native. You can check this from the macro code “dalvik/vm/jni.c: GET_PRIMITIVE_ARRAY_ELEMENTS(_ctype, _jname)”.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s