Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Drawable: layer-list repeat bitmap does not load when entirely covered

I have three full screen week views that are loaded at one time (previous, next, current). Each week view has 7 columns (one for each day of the week) with a drawable background.

My drawable resource background is

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Grey border on left and right --><item><shape><solid android:color="#999"/></shape></item>
    <!-- White background (.5pt to not cover border) --><item android:left=".5pt" android:right=".5pt"><shape>solid android:color="#FFF"/></shape></item>
    <!-- Image that repeats to make a grid --><item android:left=".5pt" android:right=".5pt"><bitmap android:src="@drawable/grid" android:tileMode="repeat" android:gravity="center" /></item>
    <!-- Times that align left. (12AM, 1AM, etc) --><item android:left="1pt" android:right=".5pt"><bitmap android:src="@drawable/grid_times" android:gravity="top|left|clip_horizontal" /></item>
</layer-list>

For some reason, if I have the three sets of seven in front of each other, only the front (visible one) gets the repeating image (actually a gif). If I shift the front over,, you can see the others do not get the repeating image

Details

The layout is RelativeLayout with three subclasses of RelativeLayout for the children. The three subclasses are identical to each other and override dispatchTouchEvent which allows them to be dragged. They start off right on top of each other so only the front one is visible. They are almost entirely identical except that one of them is on top (at first).

Here is a top view of the android

                ' first    '
                ' second   '
                ' third    '
                |          |#<-- The android screen boundaries. Only third is visible.

                   ^ ^ ^
                    user
                  looking
                  forward

when the user uses their finger to drag the view then it ends up like this (the user can see a little of the first pane (previous week) on the left)

       ' first    '
                           ' second   '
                  ' third    '
                |          |

The other way looks like this (the user can see a little of the second pane (next week))

     ' first    '
                         ' second   '
              ' third    '
                |          |

When the user lets go, they snap to this position (for now,, it will change when we fix this)

     ' first    '
                           ' second   '
                ' third    '
                |          |
like image 200
700 Software Avatar asked Feb 01 '11 00:02

700 Software


1 Answers

When you shift the front one, invalidate() the others, so they load the drawable.

like image 148
ᅙᄉᅙ Avatar answered Oct 10 '22 23:10

ᅙᄉᅙ