简体   繁体   中英

Android yearly calendar like IOS

i want to create yearly calendar in Android like ios .

such as this photo . with year , month and date .

i do it with 2 listviews and 1 gridview but , i have lag between year items .

for 50 years .with 12 month with text .


在此处输入图片说明

https://github.com/wasabeef/awesome-android-ui/blob/master/pages/Calendar.md

these libraries might help you in achieving what you want.You can try altering some of these libraries according to your need.

See this example..

https://github.com/ik024/CalendarLibrary

For YearView (this show two columns please check this code how to set the two columns than you fulfill your requirement)

在此处输入图片说明

Add the following in your xml file:

 <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"/>

Implement the YearViewClickListener in your Activity:

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
  }


}

For more refer YearViewDemo.java file.

Customizations

Following attributes can be customized:

<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" />

For three columns you need to change

go to calendarlib/layout/yearView.xml

do this... and make all change according to you responsive or etc..

    <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>

or all other in three

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM