android - Custom view unnecessarily redrawn -


i have created custom view com.mydomain.android.ktab, xml shown below, have framelayout on top , custom view @ bottom.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/radialback">  <framelayout     android:id="@+id/contentframe"      android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:layout_weight="1"     android:layout_gravity="top"     android:background="#ffcccccc"/>  <view     class="com.mydomain.android.ktab"     android:id="@+id/ktab"     android:layout_width = "fill_parent"     android:layout_height = "80dip"/>   </linearlayout> 

i programmatically add scrollview framelayout in following code:

textview tv = new textview(this); tv.settext("a long long string..."); scrollview sv = new scrollview(this); sv.addview(tv); framelayout fl = (framelayout)findviewbyid(r.id.contentframe); fl.addview(sv); 

now works when seen surface, ondraw() method of custom view(ktab in case) called when scroll contentframe, don't understand why custom view affected scrolling, it's unnecessary.

anyone give clue on this?

alright, have solved problem.

it's quite subtle problem, when put framelayout , custom view in adjacent each other, custom view invalidated(and ondraw() being called) when scroll scrollview in framelayout. guess because 2 views next each other , there's 1 pixel overlapped, when scrollview scrolled , invalidated, custom view.

the trick ensure there's @ least 1 pixel gap between framelayout , custom view, adding following framelayout properties saves life.

android:layout_marginbottom="1px"


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -