2016-08-23 37 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一樣 –