Android : Android Calendar Skeleton

on Monday, September 1, 2014


I'm trying to create a Calendar app for Android using Android Studio and I was wondering if I could get some code hints regarding how to set up a grid that will have 7 columns and 5 rows


For the rows, I'd like to have like 3-4 dates on the first row and last one, whereas for the rest 7 elements.


Cheers!


What I got so far:


My main activity:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MyActivity"
android:weightSum="1">

<LinearLayout
android:id="@+id/buttonlayout"
android:layout_width="220dp"
android:layout_height="60sp"
android:background="@drawable/topbar"
android:orientation="horizontal"
android:layout_gravity="center_horizontal">

<ImageView
android:id="@+id/prevMonth"
android:layout_width="20sp"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:src="@drawable/calendar_left_arrow_selector"/>

<TextView
android:id="@+id/currentMonth"
android:layout_width="180sp"
android:layout_height="fill_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/fontColorUnselected"/>

<ImageView
android:id="@+id/nextMonth"
android:layout_width="20sp"
android:layout_height="fill_parent"
android:src="@drawable/calendar_right_arrow_selector"
android:layout_gravity="center"/>
</LinearLayout>

<GridView
android:id="@+id/calendar"
android:layout_width="fill_parent"
android:layout_height="280dp"
android:layout_marginTop="20sp"
android:numColumns="7">
</GridView>

<ImageView
android:layout_width="127dp"
android:layout_height="100dp"
android:src="@drawable/calendar"
android:layout_gravity="center"
android:layout_weight="0.50"
android:layout_marginTop="15dp">

</ImageView>

</LinearLayout>


screen_gridcell.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/dataFieldUnselected">

<Button
android:id="@+id/calendar_day_gridcell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/fontColorUnselected"
android:background="@drawable/calendar_button_selector"
android:textSize="20dp"
/>

</RelativeLayout>


Using this, it fills up all the gap spaces, therefore I get 7 elements on each row. I would also like not to use pictures for the dates since it will load the application a bit, and try customizing things such as borders from the main activity


0 comments:

Post a Comment