i will repeat 10 of the following code but i ask for How do I shorten the following code ?
Is there a short way to repeat this code without typing it all ?
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text=" view 1 "
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="36dp" />
Define a style containing all the common attributes and set style in textview . In your case style may contain , textAlignment , textColor , textSize and if you want layout_width and layout_width also . If you want to change value for only one textview , you can always override that parameter in xml file.
<style name="TextCommanStyle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/black</item>
<item name="android:textSize">20sp</item>
</style>
your xml file.
<TextView
android:id="#+id/titleTextView"
style="#style/TextCommanStyle"
tools:text="Text 1" />
<TextView
android:id="#+id/descTextView"
style="#style/TextCommanStyle"
android:layout_marginTop="10dp"
tools:text="Text 2" />
<TextView
android:id="#+id/desc2TextView"
style="#style/TextCommanStyle"
android:layout_marginTop="10dp"
android:textColor="#color/teal_200" // override color if you want
tools:text="Text 3" />
In case you want to change textColor or add new attribute to each textview, add to a commom style and it will reflect on all view using that style.
You can create multiple styles depending upon your use case
Use an include to reused a layout without duplicating it:
https://developer.android.com/training/improving-layouts/reusing-layouts
Currently, I have the following bottom log in button.
When button is not being pressed
When button is being pressed
The XML looks like this
<LinearLayout
android:background="?attr/welcomeBottomNavBarBackground"
android:orientation="horizontal"
android:id="#+id/sign_in_bottom_nav_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
style="?android:attr/buttonBarButtonStyle"
android:id="#+id/sign_in_button"
android:layout_width="0dp"
android:width="0dp"
android:layout_weight="1.0"
android:layout_height="48dp"
android:gravity="center"
android:layout_gravity="center"
android:enabled="true"
android:textAllCaps="true"
android:text="#string/log_in" />
</LinearLayout>
I would like to remove the padding (Or should I call it margin? Please refer to my bottom most p/s section) around button when it is being pressed.
I look at How to remove padding around buttons in Android?
I had tried
<Button
...
...
android:minHeight="0dp"
android:minWidth="0dp" />
It doesn't work and has no effect.
I further try
<Button
...
...
android:background="#null"
android:minHeight="0dp"
android:minWidth="0dp" />
No more padding when pressed. However, the material designed pressed visual effect will gone too.
May I know what is the best way to remove button padding during pressed, yet retain the material designed pressed visual effect?
P/S
I don't really know whether I should call it padding or margin. What I wish to achieve is that, when we press on the bottom region, press visual effect change should be covered entire 100% bottom bar region (#+id/sign_in_bottom_nav_bar), instead of current 95% bottom bar region.
A standard button is not supposed to be used at full width which is why you experience this.
Background
If you have a look at the Material Design - Button Style you will see that a button has a 48dp height click area, but will be displayed as 36dp of height for...some reason.
This is the background outline you see, which will not cover the whole area of the button itself.
It has rounded corners and some padding and is supposed to be clickable by itself, wrap its content, and not span the whole width at the bottom of your screen.
Solution
As mentioned above, what you want is a different background. Not a standard button, but a background for a selectable item with this nice ripple effect.
For this use case there is the ?selectableItemBackground theme attribute which you can use for your backgrounds (especially in lists).
It will add a platform standard ripple (or some color state list on < 21) and will use your current theme colors.
For your usecase you might just use the following:
<Button
android:id="#+id/sign_in_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:background="?attr/selectableItemBackground" />
<!-- /\ that's all -->
There is also no need to add layout weights if your view is the only one and spans the whole screen
If you have some different idea on what your background should look like you have to create a custom drawable yourself, and manage color and state there.
As simple, use the inset property like:
android:insetTop="0dp"
android:insetBottom="0dp"
android:insetRight="0dp"
android:insetLeft="0dp"
In styles.xml
<style name="MyButtonStyle" parent="Base.Widget.AppCompat.Button">
<item name="android:background">#drawable/selector</item>
<item name="android:textColor">#android:color/black</item>
</style>
In values/drawable:
my_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="2dp" />
<!-- specify your desired color here -->
<solid android:color="#9e9b99" />
</shape>
selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="#drawable/my_drawable"/>
<item android:state_pressed="true" android:drawable="#drawable/my_drawable"/>
<item android:drawable="#android:color/transparent"/>
</selector>
In values/drawable-v21:
my_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
android:tint="?attr/colorButtonNormal"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="2dp" />
<solid android:color="#android:color/white" />
</shape>
selector.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item android:id="#android:id/mask"
android:drawable="#drawable/my_drawable" />
</ripple>
In layout:
<Button
android:id="#+id/button"
style="#style/MyButtonStyle"
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="Test"/>
Result on API 19:
Result on API 21:
Source code
I think the best solution to solve that is create your own Ripple Effect. The padding when you press the button is respecting the default Ripple Effect of the component.
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item android:drawable="?attr/colorPrimary"/>
</ripple>
Or you can try change the style of your button to style="?android:textAppearanceSmall"
Remember: This effect is only shown on Android Lollipop (API 21) or higher.
I have been through what you are going through. Long story short, you just cannot do it cleanly with a <Button> tag alone, while ensuring backwards compatibility.
The simplest and the most widely practiced method is to use a <RelativeLayout> underlay, around a <Button>.
Button Code:
<RelativeLayout
android:id="#+id/myButtonUnderlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:visibility="visible">
<Button
android:id="#+id/myButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:text="I am as cute as a Button"/>
</RelativeLayout>
Wherever you need to use a button, you use this complete code.
Here is the breakdown:
OnClick events will be hooked to myButton.
Control dimensions of your button, by changing attributes of myButtonUnderlay.
In myButton, android:background="?attr/selectableItemBackgroundBorderless". This will make it a transparent button with just the text, and backwards compatible ripples.
In myButtonUnderlay, you will do all the other background applications, like setting the color of the button, margins, paddings, borders, gradients, and shadows etc.
If manipulation of the button's visibility (programmatic or not) is wish, you do it on myButtonUnderlay.
Note: To ensure backwards compatibility, make sure that you use
android:background="?attr/selectableItemBackgroundBorderless", and NOT
android:background="?android:attr/selectableItemBackgroundBorderless"
As #David Medenjak answer you can read the Google Material design Button-style to its developer site. Use button style as #David Medenjak explained in his answer. You can also do by the following way also
It is not a padding or margin but it is actually background effect of button.
If you want to remove that then you can do as following.
Option 1:
Step 1: Put the below code in styles.xml
<style name="myColoredButton">
<item name="android:textColor">#FF3E96</item>
<item name="android:padding">0dp</item>
<item name="android:minWidth">88dp</item>
<item name="android:minHeight">36dp</item>
<item name="android:elevation">1dp</item>
<item name="android:translationZ">1dp</item>
<item name="android:background">#FF0000</item>
</style>
Step 2:Create a new XML file under drawables folder and add the following code: I named my XML file as button_prime.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#color/colorPrimary">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="1dp" />
<solid android:color="#8B8386" />
</shape>
</item>
</ripple>
Step 3: Use the style and drawable in your Button as follows.
<Button
style="#style/myColoredButton"
android:layout_width="250dp"
android:layout_height="50dp"
android:text="Cancel"
android:gravity="center"
android:background="#drawable/button_prime"
android:colorButtonNormal="#3578A9" />
Option 2:
With the Support Library v7, all the styles are actually already defined and ready to use, for the standard buttons, all of these styles are available.So you can set your button style like this
<Button
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="BUTTON"
android:gravity="center"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="#color/colorAccent"/>
For more detail of Button style please check this answer
I think you will check this answer also. I hope you will get your solution.
The padding and margin may be a result of the original resources used in the button.
So you could try to change the resources used, using a selector:
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#drawable/btn_action_hover" />
<item android:state_selected="true" android:drawable="#drawable/btn_action_hover" />
<item android:state_focused="true" android:drawable="#drawable/btn_action_hover" />
<item android:drawable="#drawable/btn_action_normal" />
</selector>
That would change the default images/shapes for your buttons, so you could try using drawables and set every item to a drawable. The drawable being either a bitmap, or a .xml file(style file) defining the look of the button in its current state. I assume there still are some native styles included even though you have set the button-style yourself. This may be because you aren't using a custom theme. So the issue may also be solved by defing
theme="#style/myNewTheme"
where myNewTheme is your theme, and it should have any parents(parent="" should not be defined).
Take any given theme(designed by Google/Android, for an instance Theme.AppCompat.[name]), it does also come with a buttonStyle. This is a part of Theme.Holo.Light:
<!-- Button styles -->
<item name="buttonStyle">#style/Widget.Holo.Light.Button</item>
<item name="buttonStyleSmall">#style/Widget.Holo.Light.Button.Small</item>
<item name="buttonStyleInset">#style/Widget.Holo.Light.Button.Inset</item>
<item name="buttonStyleToggle">#style/Widget.Holo.Light.Button.Toggle</item>
<item name="switchStyle">#style/Widget.Holo.Light.CompoundButton.Switch</item>
<item name="mediaRouteButtonStyle">#style/Widget.Holo.Light.MediaRouteButton</item>
<item name="selectableItemBackground">#drawable/item_background_holo_light</item>
<item name="selectableItemBackgroundBorderless">?attr/selectableItemBackground</item>
<item name="borderlessButtonStyle">#style/Widget.Holo.Light.Button.Borderless</item>
<item name="homeAsUpIndicator">#drawable/ic_ab_back_holo_light</item>
As you see, this theme defines how your buttons will look/work in basic features. You can override parts of it, but you haven't overridden the important parts(being buttonStyle and similar). So if you create a new theme yourself and style it to your liking and set the theme(using theme="themename") and that theme does not inherit any theme, you should be able to style your buttons to your liking without having to worry about the default styles in the theme
Basically:
calling padding/margin="0dp" will not help. The default drawable defined by the theme has this in the button drawable, meaning you cannot change it. So you have to either change the button style, or change the theme completely. Make sure that theme does not have any parents, because many themes define the button style. You do not want the button style defined by the theme.
The best solution these days is just to use MaterialButton in place of Button.
Note: MaterialButton is visually different from Button and AppCompatButton. One of the main differences is that AppCompatButton has a 4dp inset on the left and right sides, whereas MaterialButton does not. To add an inset to match AppCompatButton, set android:insetLeft and android:insetRight on the button to 4dp, or change the spacing on the button’s parent layout.
When replacing buttons in your app with MaterialButton, you should inspect these changes for sizing and spacing differences.
Source: https://material.io/develop/android/components/material-button/
I'd suggest you taking a look at this just in case before all.
Then, if not working i'd suggest you to create your own style (like azizbekian suggest)using android xml drawables, and drawable states to differentiate pressed/notpressed.
I think using your own style may be the best answer as it will further give you more control on how your app is displaying, but using android default themes and styles also allows the user to have custom styles which is a good idea. However, you cannot test every custom style so you cannot check that your app will display correctly on ALL custom styles, and therefore may encounter problems with some.
Set the Button background as android:background="?selectableItemBackground"
<LinearLayout
android:background="?attr/welcomeBottomNavBarBackground"
android:orientation="horizontal"
android:id="#+id/sign_in_bottom_nav_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
style="?android:attr/buttonBarButtonStyle"
android:background="?selectableItemBackground"
android:id="#+id/sign_in_button"
android:layout_width="0dp"
android:width="0dp"
android:layout_weight="1.0"
android:layout_height="48dp"
android:gravity="center"
android:layout_gravity="center"
android:enabled="true"
android:textAllCaps="true"
android:text="#string/log_in" />
</LinearLayout>
After trying lots of solution, Finally I came to a conclusion that with tag alone we can't achieve this. to remove this unwanted space around button my solution is as below:
<RelativeLayout
android:id="#+id/myButtonUnderlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="visible">
<Button
android:id="#+id/save_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="-5dp"
android:layout_marginBottom="-5dp"
android:layout_above="#+id/content_scrollview"
android:layout_gravity="bottom"
android:background="#drawable/ripple_theme"
android:enabled="true"
android:text="SetUp Store"
android:textColor="#fff"
android:textSize="18sp"
android:visibility="gone"
tools:visibility="visible"
style="#style/MediumFontTextView" />
</RelativeLayout>
1.add a drawable resource file named maybe button_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="#ff0000"/>
<stroke android:width="5dp" android:color="#00ff00"/>
</shape>
</item>
<item>
<shape>
<solid android:color="#00ff00"/>
</shape>
</item>
</selector>
2.Use the button_background.xml as the button background, done!
github
blog
I don't really know whether I should call it padding or margin.
The button is enacting surface elevation for providing visual feedback in response to touch. It is one of two feedbacks used for surface reaction; the first one being the ripple effect. For example, a raised button has resting state elevation of 2dp and pressed state elevation of 8dp (See raised button under Shadows). The button meets the finger as it touches the surface.
May I know what is the best way to remove button padding during pressed, yet retain the material designed pressed visual effect?
Having answered the first part, I do not believe you are having all of the material design if you wish to remove the surface elevation effect.
Anyways, here is how to remove surface elevation visual feedback:
Add animator file button_raise.xml to animator directory under res directory having the following code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:state_pressed="true">
<objectAnimator
android:duration="#android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="0dp"
android:valueType="floatType" />
</item>
</selector>
Refer newly created animator in the button using stateListAnimator property:
<Button
...
android:stateListAnimator="#animator/button_raise"
... />
Hope this helps.
I am using the following code to make a star button:
<Button
android:id="#+id/leftButton"
android:onClick = "Star"
android:layout_width="100dp"
android:layout_height="100dp"
android:Color="#FFFF00" //I tried adding this, but no luck :(
android:layout_alignParentTop="true"
android:background="#android:drawable/btn_star" />
The button currently looks white:
Is there anyway I can make it yellow?
I know I can't have two background attributes, but is there anything I can do to change the color of this star? I want to keep the star as a background attribute, rather than a source attribute, because I want to be able to change the size of it.
If you want to yellow the star icon, then you can use ColorFiler for this. As follows:
Drawable drawable = getResources().getDrawable(android.R.drawable.star);
drawable.setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
Hope this helps.
Not directly. You can add different colorized images and change them at runtime, but much better way is to use a xml drawable. For icons with xml files take a look at https://materialdesignicons.com (there are much more sites like that outside)
In the xml file you can change the color directly
Your xml file.
<Button
android:id="#+id/leftButton"
android:tint="#color/yellow_tint"
android:onClick = "Star"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:background="#android:drawable/btn_star" />
colors.xml
<resources>
<color name="yellow_tint">#FFFF00</color>
</resources>
Try it and let me know. Refer to this: Working with Drawables. I'm afraid android:color won't work in Drawables.
(background_star.xml) on drawable folder:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/star_yellow" <!-- image yellow -->
android:state_pressed="true" />
<item android:drawable="#drawable/star_normal" /> <!-- image normal-->
</selector>
on layout file:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="cancel alarm"
android:id="#+id/button2"
android:background="#drawable/background_star" <!-- change this -->
android:layout_centerHorizontal="true" />
I have a application in which i have a preference acitivty which loads my settings xml. Now, what i want to do is implement a listview of themes to enable for the application. i know how to setup a listview in the settings xml for the most part, but i dont know how to enable different themes for the application. Can anybody point me in the right direction. or have a little sample code.
Here is my Preference JAVA file, and here below that is my Settings XML.
public class Prefs extends PreferenceActivity {
ListPreference listPreference;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settingsbasic);
//New
Preference customPref = (Preference) findPreference("clearcache");
customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(getBaseContext(),
"Cache Cleared",
Toast.LENGTH_LONG).show();
WebViewClientDemoActivity.web.clearCache(true);
return false;
}
I do not have my List view yet in the code, any help would be great on how to implement. I just have a clear cache button.
Here is my settings XML.
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:key="themes"
android:title="#string/themes"
android:summary="#string/themes_list"
android:defaultValue="true" />
<CheckBoxPreference android:key="something"
android:title="#string/cache"
android:summary="#string/somethingelse"
android:defaultValue="true" />
<Preference
android:title="Clear Cache"
android:summary="Hopefully this Works"
android:key="clearcache" />
</PreferenceScreen>
I have 2 check boxes, i want to change the first check box to a list view, and have a array of the list of themes. i just dont know how to enable these themes . Do i create seperate layout files for each theme??? or so i use the themes.xml, if so how do i impletement those by click the object in the listview???
Sorry about all the questions. Any help would be great.
main.xml file, i am wanting my theme to change the contents of this main.xml. most of the attributes will stay the same.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/boardimage"
android:fadingEdge="vertical"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/boarder"
android:contentDescription="#string/title"
android:gravity="center_horizontal"
android:src="#drawable/banner" >
</ImageView>
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<WebView
android:id="#+id/webview01"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1.12" >
</WebView>
</LinearLayout>
So i want to know how i would go about changing the contents of this xml file. just as on my blue theme i will use a different drawable for the background or a different size of webview, or a image drawable in the imageview. how would i do that.
If you want to know about themes and styles, see this link of android developer :
http://developer.android.com/guide/topics/ui/themes.html
build two styles and then give the value of setting from prefrence and switch between theme , you can set themes programmatically in your activity with this code : setTheme(R.style.MyTheme);
You can do this with the following code in your themes.xml file in the values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="#android:style/Theme.Light">
<!-- hide the Window Title -->
<item name="android:windowNoTitle">true</item>
</style>
</resources>
And you can have a ListPreference with this code and add your string arrays in String.xml :
<ListPreference
android:title="List Preference"
android:summary="Select the option of the list"
android:key="listPref"
android:entries="#array/listDisplayWord"
android:entryValues="#array/listReturnValue" />
This link is useful for you : How to add multiple theme attributes to the same activity on Android Manifest?
You can use a value that give from your listPreference and switch between your layout, like this :
if(myTheme==1)
setContentView(R.layout.main1);
else
setContentView(R.layout.main2);
but the name of components(buttons,textViews, EditText,...) in the these layout must same.
I am trying to add badges to the icons in my android app. e.g. in the facebook app(for iPhone), in the home page the number of pending requests is shown on the requests icon.
Can someone provide any links/ideas on how to do this?
Thanks
If you really want to do it. Use a FrameLayout which contains an ImageView with your icon and a TextView with a ninepatch drawable as background in the right corner. Add margins to the ImageView if you want the badge to be a bit outside the icon.
Thanks Alexanderblom ,for the hints.i used that logic and manage to create badge on a internal imageicon.here is the xml file.and you have to just create a red circle on the drawable.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/frameLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="20dip"
android:layout_height="20dip"
android:text="5"
android:textColor="#color/black"
android:textStyle="bold"
android:padding="2sp"
android:gravity="center"
android:background="#drawable/circle"
android:layout_gravity="top|right" />
</FrameLayout>
and the circle.xml is
<item>
<shape android:shape="oval">
<solid android:color="#android:color/black" />
</shape>
</item>
<item android:top="1dp" android:left="1dp" android:right="1dp" android:bottom="1dp">
<shape android:shape="oval">
<solid android:color="#color/Red" />
</shape>
</item>
Android doesn't support badges on icons.
Instead, it provides the notification system (icons in the notification bar, etc), as well as the ability to create widgets that can be added to the users "desktop".
check this library which adds badge to the icon/button/tab
https://github.com/jgilfelt/android-viewbadger
Try this one, is good for Sony, Samsung, LG, HTC, Xiaomi, ASUS, ADW, APEX and NOVA Launchers.
https://github.com/leolin310148/ShortcutBadger
Follow below define steps for add notification count to app icon
Steps:
Add mavenCentral to your build script.
repositories { mavenCentral() }
Add dependencies in your app gradle.
dependencies {
compile 'me.leolin:ShortcutBadger:1.1.4#aar'
or
compile 'me.leolin:ShortcutBadger:1.1.3#aar'
}
Add the codes below for display notification count on app icon:
int badgeCount = 1;
ShortcutBadger.applyCount(context, badgeCount); //for 1.1.4
Or
ShortcutBadger.with(getApplicationContext()).count(badgeCount); //for 1.1.3
If you want to remove the badge
ShortcutBadger.removeCount(context); //for 1.1.4 ShortcutBadger.with(getApplicationContext()).remove(); //for 1.1.3
Or
ShortcutBadger.applyCount(context, 0); //for 1.1.4 ShortcutBadger.with(getApplicationContext()).count(0); //for 1.1.3