Source:
protected View onCreateDialogView() { final View view = super.onCreateDialogView(); this.palette = view.findViewById(R.id.colorPicker); this.palette.init(ColorPickerDialog.SIZE_SMALL, 4, this); view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { private boolean ignoreNextUpdate = false; public void onGlobalLayout() { if (this.ignoreNextUpdate) { this.ignoreNextUpdate = false; return; } int swatchSize = ColorPreference.this.palette.getResources().getDimensionPixelSize(R.dimen.color_swatch_small); ColorPreference.this.palette.init(ColorPickerDialog.SIZE_SMALL, (view.getWidth() - (swatchSize * 2 / 3)) / swatchSize, ColorPreference.this); this.ignoreNextUpdate = true; ColorPreference.this.drawPalette(); } }); Button button1 = view.findViewById(R.id.colorTransparentDark); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ColorPreference.this.onColorSelected(COLOR_DARK_TRANSPARENT); } }); if(ColorPreference.this.selectedColor == COLOR_DARK_TRANSPARENT) { button1.setTypeface(null, Typeface.BOLD); button1.setTextColor(Color.BLACK); } Button button2 = view.findViewById(R.id.colorTransparentWhite); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ColorPreference.this.onColorSelected(COLOR_LIGHT_TRANSPARENT); } }); if(ColorPreference.this.selectedColor == COLOR_LIGHT_TRANSPARENT) { button2.setTypeface(null, Typeface.BOLD); button2.setTextColor(Color.BLACK); } Button button3 = view.findViewById(R.id.colorTransparent); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ColorPreference.this.onColorSelected(COLOR_TRANSPARENT); } }); if(ColorPreference.this.selectedColor == COLOR_TRANSPARENT) { button3.setTypeface(null, Typeface.BOLD); button3.setTextColor(Color.BLACK); } return view; }

Target:
protected View onCreateDialogView() { final View view = super.onCreateDialogView(); this.palette = view.findViewById(R.id.colorPicker); this.palette.init(ColorPickerDialog.SIZE_SMALL, 4, this); view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { private boolean ignoreNextUpdate = false; public void onGlobalLayout() { if (this.ignoreNextUpdate) { this.ignoreNextUpdate = false; return; } int swatchSize = ColorPreference.this.palette.getResources().getDimensionPixelSize(R.dimen.color_swatch_small); ColorPreference.this.palette.init(ColorPickerDialog.SIZE_SMALL, (view.getWidth() - (swatchSize * 2 / 3)) / swatchSize, ColorPreference.this); this.ignoreNextUpdate = true; ColorPreference.this.drawPalette(); } }); Button button1 = view.findViewById(R.id.colorTransparentDark); button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ColorPreference.this.onColorSelected(COLOR_DARK_TRANSPARENT); } }); Button button2 = view.findViewById(R.id.colorTransparentWhite); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ColorPreference.this.onColorSelected(COLOR_LIGHT_TRANSPARENT); } }); Button button3 = view.findViewById(R.id.colorTransparent); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ColorPreference.this.onColorSelected(COLOR_TRANSPARENT); } }); if(ColorPreference.this.selectedColor == COLOR_DARK_TRANSPARENT) this.selectButton(button1); if(ColorPreference.this.selectedColor == COLOR_LIGHT_TRANSPARENT) this.selectButton(button2); if(ColorPreference.this.selectedColor == COLOR_TRANSPARENT) this.selectButton(button3); return view; }