使用自定义视图建立一个时间表 [英] Build a timeline using custom view

查看:123
本文介绍了使用自定义视图建立一个时间表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个Android应用程序与一个定时事件,我不知道什么布局我应该用它来建立我的时间表。

I'm building an Android App with a timed events and i'm not sure what layout i should use to build my timeline.

事件可以具有不同的高度,并且可以生长时用户点击他们,但它们具有相同的宽度;

Events can have different heights and can grow when user tap them but they have the same width;

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

我有两个观点类型:

I have two view types :

  • 使用EventView 女巫头筹信息和卓尔他的轮廓
  • TimeBarView 女巫是中等偏上的酒吧(有一定的财产,并扩展在很长的跨度
  • EventView witch hold the event info and drow his outline
  • TimeBarView witch is the bar on the middle (have some property and is extended on a very long span

我怎样才能把我的项目,因此它是恭敬的时间对我的时间线(例如1周可能是10px的)

How can i place my items so it's respectful of the time on my time-line (for example 1 week could be 10px)

任何帮助是AP preciated。 谢谢!

Any help is appreciated. Thanks !

推荐答案

我现在解决了同样的问题。

I'm tackling the same problem now.

我没有一个完整的解决方案,但我有一个想法:

I don't have a full solution yet, but I have an idea:

既然你已经双方的时间表,的ListView 是不恰当的,因为事件可以重叠。

Since you have to sides to the timeline, ListView is not appropriate because events can overlap.

而不是考虑使用2列的GridView 。我建议使用 AndroidStaggeredGrid ,支持不同项目的大小。

Instead consider using a 2-column GridView. I recommend using AndroidStaggeredGrid, that support different item sizes.

有关运行在中间实际的时间吧,我会简单地用一个窄线为背景,为GridView。

For the actual "Time bar" that runs in the middle, I'll simply use a narrow line as the background for the GridView.

会有时间轴上没有标记。取而代之的是,标记物将在使用EventView本身,无论是在左或该标记正好落在时间栏上的权利,以这样的方式。

There will be no markers on the timeline. Instead, the markers will be on the EventView themselves, either on the left or the right, in such a way that the marker falls exactly on the Time Bar.

这样,当您滚动网格,它会给错觉,时间栏本身滚动。

This way, when you scroll the grid, it will give the illusion that the Time bar itself is scrolling.

要表示一个空的时间间隔,只需添加一个空的观点,它的身高成正比,它重新presents的时间间隔。

To signify an empty time interval, just add an empty view which it's height is proportional to the interval it represents.

希望它可以帮助...

Hope it helps...

这篇关于使用自定义视图建立一个时间表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆