2016-08-23 41 views
2

我想在Android中创建年度日历iosAndroid的年度日历像IOS

如此照片。 与年份,月份和日期。

我这样做了2个listview和1个gridview,但是,我有年份项之间的差距。

50年.12个月与文本。


enter image description here

+1

只要做到这一点。什么问题? – Vyacheslav

+0

我在年份项目之间有滞后。我有沉重的过程。 –

+0

https://github.com/square/android-times-square –

回答

0

见这个例子..

https://github.com/ik024/CalendarLibrary

对于YearView(这个节目的两列,请检查这个代码如何设置比你满足自己需要的两列)

enter image description here

在您的xml文件中添加以下内容:

<com.github.ik024.calendar_lib.YearView 
    android:id="@+id/calendar_year_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true"/> 

在活动落实YearViewClickListener:

public class MonthViewDemo extends AppCompatActivity implements YearViewClickListeners{ 


@Override 
public void dateClicked(int year, int month, int day) { 
    Toast.makeText(this, "year: "+year+";\nmonth: "+month+";\nday: "+day, Toast.LENGTH_LONG).show(); 
    //TODO: Perform your actions based on year or month or day clicked 
    } 


} 

更多参考YearViewDemo.java文件。

定制

以下属性可定制:

<attr name="currentDayTextColorYV" format="color"/> 
<attr name="monthNameTextColorYV" format="color"/> 
<attr name="daysOfMonthTextColorYV" format="color"/> 
<attr name="daysOfWeekTextColorYV" format="color"/> 
<attr name="eventDayBackgroundColorYV" format="color"/> 
<attr name="eventDayTextColorYV" format="color"/> 
<attr name="calendarBackgroundColorYV" format="color" /> 
<attr name="monthNameBackgroundColorYV" format="color" /> 
<attr name="displayYearTextColorYV" format="color" /> 
<attr name="headerBackgroundColorYV" format="color" /> 
<attr name="prevButtonBackgroundResourceYV" format="reference" /> 
<attr name="nextButtonBackgroundResourceYV" format="reference" /> 

对于三列,你需要改变

去calendarlib /布局/ yearView.xml

做..并根据你的反应做出一切改变等。

<LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:weightSum="1"> 

      <com.github.ik024.calendar_lib.custom.MonthView 
       android:id="@+id/mv_year_view_jan" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.33" /> 

      <com.github.ik024.calendar_lib.custom.MonthView 
       android:id="@+id/mv_year_view_feb" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.33" /> 

      <com.github.ik024.calendar_lib.custom.MonthView 
       android:id="@+id/mv_year_view_march" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.33" /> 
     </LinearLayout> 

或所有其他三个

+0

我之前检查过这个github,但是。这个例子每个屏幕只有一年。每个可见视图只有12个月。不滚动,不像IOS一样 –