开发者

redundant onDraw() calls in FrameLayout

I have the following layout structure in my xml:

<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/mainlayout"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

    <MyEntireView
            android:id="@+id/map"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">
    </MyEntireView>

    <FrameLayout
            android:id="@+id/focusedlayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom">

           <MyDetailedView
              android:id="@+id/focus"
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent">
           </MyDetailedView>
    </FrameLayout>
</FrameLayout>

MyEntireView is a map (a Drawable) and MyDetailedView pops up on top of it upon onTouch() and contains only a certain piece of the whole map (also Drawable) that displays in greater detail the area which the user touched on the entire map in MyEntireView.

When MyDetailedView is shown - i.e. its setVisibility(View.VISIBLE) - there appear some transparent shapes (also some Bitmaps) on top and are redrawn regularly (e.g., 1 sec interval). The shapes are added dynamically as children of the @+id/focusedlayout as there is always a different number of them and their position is relevant to the detailed map picture.

And the problem is that each single update is processed multiple times. Each time a shape updates, then MyEntireView's onDraw() is called, MyDetailedView's onDraw() is called, and then these two are called again. And only after this the shape itself is invalidated.

As a result, this behaviour makes the shape flicker, since MyDetailedView redraws and hides the shape for 10ms or so.

I must probably be overlooking some simple logic, but I really can't get if there is a way to force onl开发者_运维技巧y one View of a ViewGroup invalidate().

Or maybe there is an alternate structure/layout that I could use to fit my purpose?

Thanks a lot!

P.S. The entire code is quite big to put here but I'm willing to insert any pieces upon request

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜