Skip to content

Commit

Permalink
【Jiang】:时间选择项的今日文字变成了按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
jxr202 committed Jul 2, 2018
1 parent d79f98a commit f09a1bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
5 changes: 1 addition & 4 deletions colorful-ui-example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
jxr202:mTitleViewText="@string/date_title"
jxr202:mTitleViewTextColor="#2C9BB6"
jxr202:mTitleViewTextSize="16dp"
jxr202:mTodayText="@string/date_today"
jxr202:mTodayTextBackground="#50D2C2"
jxr202:mTodayTextColor="#ffffff"
jxr202:mTodayTextSize="16dp" />
jxr202:mTodayViewSrc="@mipmap/date_today" />

<TextView
android:id="@+id/tv_date"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DateSelectView extends RelativeLayout {
private ImageView mDateLeft;
private ImageView mDateRight;
private TextView mDateTitle;
private TextView mDateToday;
private ImageView mDateToday;

private int mDateTitleId;
private Context mContext;
Expand Down Expand Up @@ -63,31 +63,20 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) {
mDateLeft = new ImageView(context);
mDateRight = new ImageView(context);
mDateTitle = new TextView(context);
mDateToday = new TextView(context);
mDateToday = new ImageView(context);

TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DateSelectView, defStyleAttr, 0);

mDateLeft.setImageDrawable(array.getDrawable(R.styleable.DateSelectView_mLeftViewSrc));
mDateRight.setImageDrawable(array.getDrawable(R.styleable.DateSelectView_mRightViewSrc));
mDateToday.setImageDrawable(array.getDrawable(R.styleable.DateSelectView_mTodayViewSrc));

mDateTitleId = array.getResourceId(R.styleable.DateSelectView_mTitleViewId, R.id.date_title);
mDateTitle.setId(mDateTitleId);
mDateTitle.setText(array.getString(R.styleable.DateSelectView_mTitleViewText));
mDateTitle.setTextSize(px2dip(array.getDimension(R.styleable.DateSelectView_mTitleViewTextSize, 16)));
mDateTitle.setTextColor(array.getColor(R.styleable.DateSelectView_mTitleViewTextColor, 0xff2C9BB6));

mDateToday.setGravity(Gravity.CENTER);
mDateToday.setText(array.getString(R.styleable.DateSelectView_mTodayText));
mDateToday.setTextSize(px2dip(array.getDimension(R.styleable.DateSelectView_mTodayTextSize, 16)));
mDateToday.setTextColor(array.getColor(R.styleable.DateSelectView_mTodayTextColor, 0xffffffff));

int backgroundColor = array.getColor(R.styleable.DateSelectView_mTodayTextBackground, 0xff3e6373);
GradientDrawable drawable = new GradientDrawable();//创建drawable
drawable.setColor(backgroundColor);
drawable.setCornerRadius(dp2px(25));
drawable.setStroke(dp2px(1), backgroundColor);
mDateToday.setBackground(drawable);

array.recycle();

initCalendar();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions colorful-ui/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@
<enum name="visible" value="0" />
</attr>

<attr name="mTodayText" format="color|reference"/>
<attr name="mTodayTextSize" format="dimension"/>
<attr name="mTodayTextColor" format="color"/>
<attr name="mTodayTextBackground" format="color|reference"/>
<attr name="mTodayTextVisibility">
<attr name="mTodayViewId" format="reference|integer"/>
<attr name="mTodayViewSrc" format="color|reference"/>
<attr name="mTodayViewVisibility">
<enum name="gone" value="8" />
<enum name="invisible" value="4" />
<enum name="visible" value="0" />
Expand Down

0 comments on commit f09a1bb

Please sign in to comment.