Example usage for android.widget LinearLayout getMinimumWidth

List of usage examples for android.widget LinearLayout getMinimumWidth

Introduction

In this page you can find the example usage for android.widget LinearLayout getMinimumWidth.

Prototype

public int getMinimumWidth() 

Source Link

Document

Returns the minimum width of the view.

Usage

From source file:arun.com.chromer.settings.widgets.PreferenceIconLayoutHelper.java

/**
 * Applies layout changes on the preference icon view so that it does not look overly big.
 *
 * @param holder  the preference view holder
 * @param checked if the preference is enabled
 *//*w  w  w  .  ja  v a 2  s  . co m*/
static void applyLayoutChanges(@NonNull PreferenceViewHolder holder, boolean checked) {
    try {
        final LinearLayout iconFrame = (LinearLayout) holder
                .findViewById(android.support.v7.preference.R.id.icon_frame);
        final ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);

        if (iconFrame.getMinimumWidth() != 0) {
            iconFrame.setMinimumWidth(0);
            imageView.setScaleType(ImageView.ScaleType.CENTER);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            int dp12 = Utils.dpToPx(12);
            params.setMargins(dp12, 0, dp12, 0);
            imageView.setLayoutParams(params);
        }

        applyIconTint(imageView, checked);
    } catch (Exception e) {
        Timber.e(e);
    }
}