« first day  last day (14 days later) » 

16:59
Hi Vikram, I think I found my answer
As in the middle of testing, I realize it is not necessary to let the button style inherit from X style
I can just use <style name="Shop_Button">
It make no difference than
Yes, you are correct
<style name="Shop.Button.Light" parent="@style/Theme.MyAppTheme.Light">
But
BUT, if your widget uses some attrs which are customized under your app's theme, then inheriting from your app theme is required..
17:01
<style name="SelectiveActionBarButtonTheme" parent="AppTheme"> is difference case right?
Do you wish to know another approach?
Yes. Please.
This approach is a bit more verbose..
We will try and recreate the button's background
This will go under res/drawable-v21
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/ripple_material_dark">
<item android:drawable="@drawable/custom_btn_shape" />
</ripple>
Next we define: res/drawable/custom_btn_shape.xml
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="4dp"
android:insetTop="6dp"
android:insetRight="4dp"
android:insetBottom="6dp">
<shape android:shape="rectangle"
android:tint="@color/shop_button_background_color_material_light">
<corners android:radius="2dp" />
<solid android:color="@android:color/white" />
<padding android:left="8dp"
android:top="4dp"
android:right="8dp"
android:bottom="4dp" />
</shape>
</inset>
17:11
OK. This sounds more complicated. Is this code being picked from Google's, or you figure out your own?
Now, you need not create any new styles, nor set android:theme...
I prefer to use the theme technique introduced by you.
For the more verbose method, I do use it in the following case.
Is during dealing with the positive button in dialog
This is from Android's source code with relevant changes: androidxref.com/6.0.1_r10/xref/frameworks/base/core/res/res/…
As, there is no way to change the positive button style during runtime in java code.
0
A: How to change material designed dialog positive button background correctly

Cheok Yan ChengBy referring http://stackoverflow.com/a/27505229/72437, I was able to change the background of positive button, without affecting its default margin, padding and selector behavior. Note that, we don't use colorButtonNormal, as there is no way to change the button style in Java code. dimens.xml <...

Do you think I'm doing correctly? Or, I am making the solution complicated?
Let me take a look
Can you please take a look at this answer of mine: stackoverflow.com/questions/28523707/…
I think if you override colorButtonNormal under CusButtonBarButtonStyle, you can achieve the same result..
But, your approach of recreating the Button's background using InsetDrawable is also quite good..
17:23
I think by using your approach, the style will be applied to all buttons right?
I remember this afternoon, I came across one attribute (Something called positive button attribute, can't remember the exact name)
Ahh, nice catch
I try to hack it, but it doesn't work some how. I might be missing something
But wait, in my answer, we override <item name="android:buttonBarButtonStyle">@style/CusButtonBarButtonStyle</item>
Instead of this, you can override buttonBarPositiveButtonStyle and that should only affect the RATE button
By default, ?attr/buttonBarPositiveButtonStyle is set to ?attr/buttonBarButtonStyle...
Do you mean?
<style name="CusAlertDialogTheme"
parent="android:Theme.Material.Dialog.Alert">
<item name="android:buttonBarPositiveButtonStyle">@style/CusButtonBarButtonStyle</item>
</style>
Yes
17:30
That's sound like a better solution than my current "complicated". Going to give it a try.
U think this stackoverflow.com/a/31456997/72437 is correct answer?
As I saw its buttonBarPositiveButtonStyle, is not inherit from any parent.
No, that's not the right answer
Let me first check in my BUY button code, then I will try out
<style name="CusAlertDialogTheme"
parent="android:Theme.Material.Dialog.Alert">
<item name="android:buttonBarPositiveButtonStyle">@style/CusButtonBarButtonStyle</item>
</style>
thank you very much. I think `<style name="CusAlertDialogTheme"
parent="android:Theme.Material.Dialog.Alert">` code is easier to maintain, if that works.
Like you noticed, there's not parent theme defined.. To be consistent, we only change the things we want to customize... Everything else comes from the parent
Unfortunately, user sosite's answer is a hack at best..
By the way...
Even if overriding colorButtonNormal under buttonBarPositiveButtonStyle does not work, you can make your own solution (on this page: Link) a bit better...
May I know what else I can make my own solution a bit better?
Under @style/CusButtonBarButtonStyle, override android:background: <item name="android:background">@drawable/rate_app_dialog_positive_button_selector_mat‌​erial_light</item>
This way you don't have to resolve attributes at runtime.. and DialogInterface.OnShowListener will not be required..
17:44
I realize some weird thingy
The 2nd row
Is the text copy from your conversation
But, it is different from the text i copy from my stackoverflow answer
are u using some special encoding?
I do not think so.. :))
Not sure what's happening there
I think is something wrong with the 'e' character i copy from stackoverflow
You're right, I made the switch from notepad++ to sublime..
Shows me 1 of 2 matches.. :)
18:04
Hem...
Widget.Material.Button.Borderless.Colored is only for v21
I think I need to create v21 folder for this style.
What is the minSdkVersion for your app?
API 14 (Android 4.0)
I guess
Then, you can use The app-compat version of this style: Widget.AppCompat.Button.Borderless.Colored
maybe use this
Widget.AppCompat.Button.Borderless
oh
ok
Right
`<style name="CusAlertDialogTheme"
parent="android:Theme.Material.Dialog.Alert">` will also change to: `<style name="CusAlertDialogTheme"
parent="Theme.AppCompat.Light.Dialog.Alert">`
18:18
Yes. Testing right now...
Does look positive at first try
Let me send u screenshot
I had tested parent="@style/Widget.AppCompat.Button", parent="@style/Widget.AppCompat.Button.Colored" and parent="@style/Widget.AppCompat.Button.Borderless.Colored"
My changes is
final AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(this.getContext(), R.style.RateAppDialog))
<style name="RateAppPositiveButton" parent="@style/Widget.AppCompat.Button.Borderless.Colored">
<item name="colorButtonNormal">#ff0000</item>
</style>

<style name="RateAppDialog" parent="@style/Theme.AppCompat.Light.Dialog.Alert">
<item name="android:buttonBarPositiveButtonStyle">@style/RateAppPositiveButton</item>
<item name="buttonBarPositiveButtonStyle">@style/RateAppPositiveButton</item>
</style>
Ok, to avoid passing R.style.RateAppDialog, you can have <item name="android:alertDialogTheme">@style/RateAppDialog</item>
But, that will affect my entire app right? I only want this effect applicable to this dialog.
The positive button is not visible in the screenshot... am I right?
18:29
yup. but selector effect seem right
No.. it will affect only alert dialogs
no. what i mean, that will affect my other alert dialogs right?
Yes..
:D I only want it to be in "Rate me" dialog
I try to keep all styling in xml.. :))
But, in your specific case, passing R.style.RateAppDialog is fine
So, problem solved then?
I am very impressed that you're putting in so much effort in doing things properly...
18:35
Nope. As you can see, u can see the normal blue color effect is gone, after using this theme technique
But, I think it is fine for now. As complicated way works for me.
I need to tackle other UI area :(
What did we miss? Give a minute..
Give me a minute*
ok.
I'm also impressed with your deep knowledge on how Android in-and-out.
I try to do it in pixel-perfect sense. If not, it is very difficult to stand out of competitive app market.
18:52
Hi there?
Yea, doing a bit of testing on my end..
I have to leave soon... So, I'll look at this in detail after I get back..
If that too much of effort, it is ok for me to stick with complicated solution.
Thank you very much!
I will email you as and when I find the cause of this..
18:54
Thank u.
No no, I think this will help me too.. :)
Talk to you soon then, have a good night..
Good night to you too :)

« first day  last day (14 days later) »