SimplicityApks / ReminderDatePicker

A Google Keep-like Date and Time Picker for reminders
Apache License 2.0
74 stars 26 forks source link

simplify style adaptation #22

Closed avp90 closed 9 years ago

avp90 commented 9 years ago

Hello, could you outsource the attributes of the DateSpinner and TimeSpinner in Styles.

SimplicityApks commented 9 years ago

Hi, I'm not sure what your problem is, as you can already configure the attributes using the flags xml attribute. That one is also accessible in your styles, just use

<style name="CustomStyle">
   <item name="flags">more_time|month</item>
</style>

for instance and then apply that style to the ReminderDatePicker or spinner in the xml layout file. See here for more help.

avp90 commented 9 years ago

Hi, I mean the Style of the controls like layout_width, layout_height, font size ... I want to customize the appereance of the DateSpinner and TimeSpinner.

SimplicityApks commented 9 years ago

OK now I get it... I'll have a look at it, probably have to change the way the Spinners are initialized in ReminderDatePicker as we can't set styles programmatically.

SimplicityApks commented 9 years ago

Well this is harder than I thought... I tried initializing the Spinners in the ReminderDatePicker's init() method, and that worked fine at first but broke restoring the Spinner selection and items after rotation (and also setting layout_height and layout_width wasn't possible). I am now looking into themes, there must be a more direct way to pass a style to all DateSpinner and TimeSpinner views in the activity (like it is done with android:buttonStyle in an app theme).

But I think that it might be easier for you if you'd just copy the ReminderDatePicker class and replace R.layout.reminder_date_picker with your custom xml layout file using the styles. I have to think about that, it may be useful to have a separate xml attribute, let's say spinnerLayout, which you can pass to the ReminderDatePicker in xml.

avp90 commented 9 years ago

I think I have the solution for this problem. I'll send you a pull Request at the weekend. Thank you for your efforts to find a solution.

SimplicityApks commented 9 years ago

ok lol well I just decided to implement the custom layout file (that way you can also insert a divider view in the middle) and that works fine. Only thing is, you need to copy & paste the reminder_date_picker layout file and apply the spinner styles there. If you're ok with that, we'll take my implementation so you don't need to work on it yourself. Otherwise I'm excited for your solution, we'll see which is nicer ;)

avp90 commented 9 years ago

Challenge accepted :-) I have a similar solution for this.

SimplicityApks commented 9 years ago

Congrats, you won! :+1: That is definitely nicer than everything I had in mind ;). Good idea with overriding the styles, I didn't know that's possible.