Building a timeline using a custom view

I am creating an Android application with synchronized events, and I'm not sure which layout I should use to build the timeline.

Events can have different heights and can increase when you click on them, but they have the same width;

              .
              .
              .
------------- |
| Event 4   > | --------------
------------- | < Event 7    |
              | |            |
              | --------------
              .
              .
              .

I have two types of views:

  • EventView witch holds event information and throws his plan
  • TimeBarView witch is a strip in the middle (has some property and extends over a very long period of time

How can I place my items so that he respects the time on my timeline (for example, 1 week can be 10px)

Any help is appreciated. Thank!

+5
source share
2 answers

.

, :

, ListView , .

2- GridView. AndroidStaggeredGrid, .

" ", , GridView.

. EventView , , , , .

, , , .

, , .

, ...

+1

, , , , RelativeLayout, , , . leftMargin "", RelativeLayout.LEFT_OF

, Android. onMeasure onLayout. onMeasure , ( , ), .

onLayout :

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            // do the layout for each child here, with child.layout
            // e.g., child.layout(0, 0, r, b);
    }
}

View.layout 4 : , , - . l, t, r b.

0

All Articles