SpongeBobSun / mCalendarView

Customizable & Shrinkable Calendar Widget for Android
Apache License 2.0
243 stars 73 forks source link

How to edit the style of the title ? #79

Open bhishman-desai opened 4 years ago

humanmatt commented 4 years ago

Hi @desaibhishman did you manage to Edit the title style?

I think the title is set here:

public class MonthFragment extends Fragment { private MonthData monthData; private int cellView = -1; private int markView = -1; private boolean hasTitle = true; public void setData(MonthData monthData, int cellView, int markView){ this.monthData = monthData; this.cellView = cellView; this.markView = markView; }

public void setTitle(boolean hasTitle){
    this.hasTitle = hasTitle;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState){
    LinearLayout ret = new LinearLayout(getContext());
    ret.setOrientation(LinearLayout.VERTICAL);
    ret.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    ret.setGravity(Gravity.CENTER);
    if(hasTitle){
        TextView textView = new TextView(getContext());
        textView.setText(String.format("%d-%d", monthData.getDate().getYear(), monthData.getDate().getMonth()));
        ret.addView(textView);
    }

    MonthView monthView = new MonthView(getContext());
    monthView.setAdapter(new CalendarAdapter(getContext(), 1, monthData.getData()).setCellViews(cellView, markView));
    ret.addView(monthView);
    return ret;
}

}

Not sure how you would edit it as it is read-only?

humanmatt commented 4 years ago

As Stated in Previous response from @SpongeBobSun :

"MCalendarView does not contain a title text view. You should add one yourself in your layout file. So yes, you can show anything you like in the title view."