android chips taking extra spaces;unable to wrap

add chips dynamically android
android chip selected color
android chip style programmatically
chip text size android
android chip background drawable
input chips in android
android chip outline
android chipgroup spacing

I use chipgroup with dynamic chips. I want the chips to get wrapped in width according to their text. But it takes extra spaces even without padding.

Below is my code:



This is how to add chips dynamically:

for(int i=0;i<cartoonTypes.length;i++){
    chip = new Chip(this);
    chip.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
    ChipGroup.LayoutParams layoutParams = (ChipGroup.LayoutParams) chip.getLayoutParams();;
    int dpSize = px2dp(12);;
    layoutParams.height = dpSize;
    layoutParams.width = ChipGroup.LayoutParams.WRAP_CONTENT;

method px2dp does this:

int px2dp(int px){
    metrics = new DisplayMetrics();
    int h = (px * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
    return h;

My build.gradle has the following dependencies:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.cardview:cardview:1.0.0-beta01'
implementation ''

This is what I see:

I want the chip to use as minimal width as possible according to its text.

You should set padding for chip in right way, try this:


Chips, Chips represent complex entities in small blocks, such as a contact. <com.​ android:layout_width="wrap_content" If you do so, you'll usually want to wrap the ChipGroup in a HorizontalScrollView . A ChipGroup can insert spacing between chips in a row or between rows of chips using  10 quick ways to clear space on an overstuffed Android device Zap cached app files in a single tap, clear the Downloads folder, delete unneeded offline maps, take charge of music downloads, and more.

I have been trying to add chips to a chips group dynamically, but the , I have been trying to add chips to a chips group dynamically, but the chips don't seem to wrap the text completely and text isn't aligned in the  Apps probably take up most of the storage space on your phone. If you've got an Android phone that lets you add a microSD card for extra storage, you may be able to move some of your

Probably just removing chip.setTextSize() may help you get rid of the space on the right (however, I'm still wondering how to change the font size). If not, this is the solution I use in my project:

  1. Define a style for your chips:
    <style name="ListChip" parent="Widget.MaterialComponents.Chip.Entry" >
        <style name="ListChip" parent="Widget.MaterialComponents.Chip.Entry" >
        <item name="rippleColor">@null</item>
        <item name="closeIcon">@null</item>
        <item name="chipBackgroundColor">?attr/background_highlight_color</item>
        <item name="android:checkable">false</item>
        <item name="android:textSize">8sp</item> //This has not effect
        <item name="android:textColor">?attr/text_color</item>
  1. Create a layout resource file with the root element and apply the newly created style:
    <?xml version="1.0" encoding="utf-8"?>
  1. In the code, create your chips not by using Chip chip = new Chip(this); but by inflating the newly created chip layout:
    Chip chip = (Chip) LayoutInflater.from(chipGroup.getContext()).inflate(R.layout.chip_in_list, chipGroup, false);
  1. Do not call chip.setTextSize() on the newly created chip.

Developers Who Use Spaces Make More Money Than Those Who , Do you use tabs or spaces for code indentation? associated with as high a salary difference as an extra 2.4 years of experience. difficult to make the effect shrink and basically impossible to make it disappear. Surely, it takes more time to add 3 spaces than a tab, which would Chip Overclock® says:. The HUD chips won’t take up a lot of space, but the more powerful ones will demand 10 units and more. To spec out your characters without having to sacrifice your HUD information, you’ll have to

to include an mdl chip component, Chips. Dialogs. Layout. Lists. Loading. Menus. Sliders. Snackbar. Toggles. Tables. Text Fields. Tooltips. COMPONENTS: Material Design Lite (MDL) is a library  Manufacturers tend to overcharge for extra storage, so it often seems like a good place to save money. But apps and games are getting bigger all the time, and we all like to take photos and shoot

COVID-19 Updates, Why localized compensation in a work-anywhere world isn't so simple (Extra Crunch) May 26, 2020. France's data protection watchdog reviews contact-​tracing  If your phone has a MicroSD card slot, you can use it to expand your space for music, movies or even apps, thanks to the improved SD card features in Android 6.0 Marshmallow. This seems like a big change for Google.

Hands-on with Material Components for Android: Chips, This post will be covering the features and API of Chip components. Setting up a Material Components theme for Android Optionally wrap ChipGroup in a HorizontalScrollView for scrolling behavior The spacing between grouped Chip s (which defaults to 8dp) can be adjusted with the chipSpacing  To overcome the problem of reduced internal storage space, several high-end smartphones are sold with free cloud storage accounts. This could be 10, 20 or even 50GB. Whilst this is a nice extra, bear in mind that not all data and files can be saved to cloud storage (apps for example).

Heading Spacing in Canvas Pages, So I took the page you created and put it in my test course and looked at it on my Android phone. See the image below. It looks evenly spaced. Adoptable SD Card is an Android feature that allows an external SD card to be used as internal storage. The data stored on an Adopted card is encrypted and it can't be mounted on any other device.

  • It reduces the space, but still has some space left and my gravity attribute is not working.It has some space on top even after trying many gravity attributes!
  • I increased my chip height, and the gravity is fine now, but there is some more space present on the left and right..any inputs on them !!
  • Add setTextStartPadding(0) and setTextEndPadding(0) to see if it would better meet your needs.
  • thanks, but there is an extra space only on the right now for some texts inspite of trimming the strings!
  • if u dont mind could u have a look at this post on Sajith's…