Stylizing material buttons in Android v21 -
i trying maintain material design ripple effect devices lollipop , above (21+) , stylize button doesn't have large margin/space around it.
example 1: buttons ripple effect margin/gap:
example 2: buttons no ripple effect , without margin/gap:
i want layout of exmaple 2 ripple effect used in example 1.
what styles-v21
example 1 :
<?xml version="1.0" encoding="utf-8"?> <resources> ... other styles ... <style name="facebookbutton" parent="android:widget.material.button"> <item name="android:colorbuttonnormal">#ff3b5998</item> <item name="android:layout_margin">0dp</item> <item name="android:borderlessbuttonstyle">@style/widget.appcompat.button.borderless</item> </style> <style name="googlebutton" parent="android:widget.material.button"> <item name="android:colorbuttonnormal">#ffdd4b39</item> <item name="android:layout_margin">0dp</item> <item name="android:borderlessbuttonstyle">@style/widget.appcompat.button.borderless</item> </style> <style name="twitterbutton" parent="android:widget.material.button"> <item name="android:colorbuttonnormal">#ff55acee</item> <item name="android:layout_margin">0dp</item> <item name="android:borderlessbuttonstyle">@style/widget.appcompat.button.borderless</item> </style> <style name="skipbutton" parent="android:widget.material.button"> <item name="android:colorbuttonnormal">#ffdfa800</item> <item name="android:layout_margin">0dp</item> <item name="android:borderlessbuttonstyle">@style/widget.appcompat.button.borderless</item> </style> </resources>
what button layout looks example 1:
<button android:id="@+id/login_with_facebook" android:text="@string/login_with_facebook" android:fontfamily="sans-serif-condensed" android:textsize="16sp" android:drawableleft="@drawable/facebook_icon" android:drawablepadding="25dp" android:layout_width="match_parent" android:layout_height="45dp" android:layout_weight="16.88" android:textcolor="#ffffff" android:gravity="left|center_vertical" android:paddingleft="45dp" android:theme="@style/facebookbutton" /> <button android:id="@+id/login_with_google" android:text="@string/login_with_google" android:fontfamily="sans-serif-condensed" android:textsize="16sp" android:drawableleft="@drawable/google_icon" android:drawablepadding="25dp" android:layout_width="match_parent" android:layout_height="45dp" android:layout_weight="16.88" android:textcolor="#ffffffff" android:gravity="left|center_vertical" android:paddingleft="45dp" android:theme="@style/googlebutton" /> <button android:id="@+id/twitter_login_button" android:text="@string/login_with_twitter" android:fontfamily="sans-serif-condensed" android:textsize="16sp" android:drawableleft="@drawable/twitter_icon" android:drawablepadding="25dp" android:layout_height="45dp" android:gravity="left|center_vertical" android:layout_width="match_parent" android:layout_weight="16.88" android:textcolor="#ffffffff" android:paddingleft="45dp" android:theme="@style/twitterbutton" /> <button android:id="@+id/login_anonymously" android:text="@string/login_anonymously" android:fontfamily="sans-serif-condensed" android:textsize="16sp" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="50" android:textcolor="#ffffffff" android:theme="@style/skipbutton" />
any idea how can achieve of example 2 while using ripple methodology i've presented? links resources or appreciated. thanks.
extra:
i've read on following
you can use android:background="?android:attr/selectableitembackground"
rectangular ripple.
alternatively, can create own drawable. here's xml framework's selectable item background:
drawable/item_background_material.xml:
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:attr/colorcontrolhighlight"> <item android:id="@android:id/mask"> <color android:color="@android:color/white" /> </item> </ripple>
Comments
Post a Comment