add arrow icons for switching the month
|
@ -1,8 +1,10 @@
|
|||
package calendar.simplemobiletools.com;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
@ -12,19 +14,30 @@ import org.joda.time.DateTime;
|
|||
import java.text.DateFormatSymbols;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private DateTime targetDate;
|
||||
private int grey;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
grey = getResources().getColor(R.color.darkGrey);
|
||||
|
||||
final ImageView leftArrow = (ImageView) findViewById(R.id.left_arrow);
|
||||
leftArrow.getDrawable().mutate().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
final ImageView rightArrow = (ImageView) findViewById(R.id.right_arrow);
|
||||
rightArrow.getDrawable().mutate().setColorFilter(grey, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
final TextView monthTV = (TextView) findViewById(R.id.table_month);
|
||||
|
||||
final TableLayout tableHolder = (TableLayout) findViewById(R.id.table_holder);
|
||||
final LayoutInflater inflater = getLayoutInflater();
|
||||
|
||||
final DateTime now = new DateTime();
|
||||
monthTV.setText(getMonthName(now));
|
||||
targetDate = now;
|
||||
monthTV.setText(getMonthName());
|
||||
final int currMonthDays = now.dayOfMonth().getMaximumValue();
|
||||
|
||||
final int firstDayIndex = now.withDayOfMonth(1).getDayOfWeek() - 1;
|
||||
|
@ -44,7 +57,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
currDate = prevMonthStart + cur;
|
||||
} else if (currDate <= currMonthDays) {
|
||||
thisMonthDays++;
|
||||
day.setTextColor(getResources().getColor(R.color.darkGrey));
|
||||
day.setTextColor(grey);
|
||||
} else {
|
||||
currDate = nextMonthsDay++;
|
||||
}
|
||||
|
@ -58,8 +71,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private String getMonthName(DateTime dateTime) {
|
||||
private String getMonthName() {
|
||||
final String[] months = new DateFormatSymbols().getMonths();
|
||||
return months[dateTime.getMonthOfYear() - 1];
|
||||
return months[targetDate.getMonthOfYear() - 1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,22 +4,44 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/activity_margin"
|
||||
tools:context="calendar.simplemobiletools.com.MainActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/left_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/table_month"
|
||||
android:layout_alignTop="@+id/table_month"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:src="@mipmap/arrow_left"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/table_month"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/activity_margin"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:textColor="@color/darkGrey"
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/right_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/table_month"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/table_month"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:src="@mipmap/arrow_right"/>
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/table_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/table_month"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:gravity="center">
|
||||
|
||||
</TableLayout>
|
||||
|
|
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 828 B |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 897 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 897 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 897 B |