Skip to main content

Android button customization

<?xml version="1.0" encoding="utf-8"?>
<ripple
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="#DDDDDD">

    <item>
    <selector>
        <item android:state_selected="true">
            <color android:color="#EEEEEE" />
        </item>

        <item android:state_activated="true">
            <color android:color="#EEEEEE" />
        </item>

        <item>
            <color android:color="#FFFFFF" />
        </item>
    </selector>
    </item>
</ripple>
or add this to make a shape
<item>    
  <shape android:shape="rectangle">        
    <corners android:radius="50dp"/>        
    <solid android:color="#4444ff"/>    
  </shape>
</item>

ImageButton can not hold text inside. Button gets a shadow and ImageButton does not.
Add text view and image button inside a frame layout to display text inside the image button. This will not make a shadow effect.

Does not apply ripple effect if used selector drawable.

Buttons

Most buttons are made with several drawables. Usually you’ll have a pressed and normal version of assets like this:
/drawable/button.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@drawable/button_pressed"/>
    <item android:drawable="@drawable/button_normal"/>
</selector>
If you have a custom button with selected state, your text color changes depending on the state, etc. So default button background is not going to work for you here. You can add this feedback for your own drawables and for custom buttons by simply wrapping them in a ripple element:
/drawable-v21/button.xml:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item android:drawable="@drawable/button_normal" />
</ripple>

Comments

Popular posts from this blog

React material-ui [version1] TextField customize

React material-ui v0.x gives the opportunity to customize elements by overriding styles easily. When it comes to latest version v1, it becomes a bit difficult to do that similar as the earlier version. But they have given more options to customize elements by theming, overriding with classes and JSS. So you have to be a reactJs or Mui expert to understand those stuff with the documentation other than the earlier version. (This tutorial for react/ mui beginners to migrate from version 0.x) I will show you both version styling examples to do complete AtoZ customization to a TextField.

Defer loading of JavaScript

To prevent JavaScript from blocking page loading, we recommend using the HTML async attribute when loading JavaScript. For example: <script async src="my.js"> If your JavaScript resources use document.write, it is not safe to use asynchronous loading. We recommend that scripts that use document.write be rewritten to use a different technique. Additionally, when loading JavaScript asynchronously, if your page loads scripts that depend on one another, care must be taken to make sure that your application loads scripts in the proper dependency order. If the external scripts are small, you can include them directly into the HTML document. Inlining small files in this way allows the browser to proceed with rendering the page.

Customize ActionBar | Android Dev

How to change; Actionbar color? Statusbar color? Statusbar text color? **Set this style for the relevant activity <style name= "ThemeActionBar" parent= "ThemeOverlay.AppCompat.Light" > <!-- title text color --> <item name= "android:textColorPrimary" > @color/colorBlack </item> <!-- subtitle text color --> <item name= "android:textColorSecondary" > @color/colorBlack </item> <!-- action menu item text color --> <item name= "actionMenuTextColor" > @color/colorBlack </item> <!-- action menu item icon color - only applies to appcompat-v7 icons :( --> <item name= "colorControlNormal" > @color/colorBlack </item> <!-- enable actionbar --> <item name= "windowActionBar" > true </item> <item name= "windowNoTitle" > false </item> ...