Example usage for android.widget LinearLayout getLayoutParams

List of usage examples for android.widget LinearLayout getLayoutParams

Introduction

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

Prototype

@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
public ViewGroup.LayoutParams getLayoutParams() 

Source Link

Document

Get the LayoutParams associated with this view.

Usage

From source file:de.spiritcroc.modular_remote.Util.java

public static void resizeLayoutWidth(View containerView, LinearLayout layout, double size,
        int valueForNegativeSize) {
    if (size > 0) {
        layout.getLayoutParams().width = getWidthFromBlockUnits(containerView, size, false);
    } else {/*from w ww.ja  v  a  2 s .  co  m*/
        layout.getLayoutParams().width = valueForNegativeSize;
    }
    layout.requestLayout();
}

From source file:de.spiritcroc.modular_remote.Util.java

public static void resizeLayoutHeight(View containerView, LinearLayout layout, double size,
        int valueForNegativeSize) {
    if (size > 0) {
        layout.getLayoutParams().height = getHeightFromBlockUnits(containerView, size, false);
    } else {//from w  ww. j  av a  2  s  .c o m
        layout.getLayoutParams().height = valueForNegativeSize;
    }
    layout.requestLayout();
}

From source file:com.android.inputmethod.keyboard.EmojiLayoutParams.java

public void setCategoryPageIdViewProperties(LinearLayout ll) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
    lp.height = mEmojiCategoryPageIdViewHeight;
    ll.setLayoutParams(lp);/*from  w ww  . j  ava  2s.  c  o  m*/
}

From source file:com.android.inputmethod.keyboard.EmojiLayoutParams.java

public void setActionBarProperties(LinearLayout ll) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
    lp.height = mEmojiActionBarHeight - mBottomPadding;
    ll.setLayoutParams(lp);//from  ww w . j  a  v  a  2s .  c  o  m
}

From source file:com.android.inputmethod.keyboard.emoji.EmojiLayoutParams.java

public void setActionBarProperties(final LinearLayout ll) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
    lp.height = getActionBarHeight();//  w  w  w.j  a  v  a 2 s. c o m
    ll.setLayoutParams(lp);
}

From source file:net.xisberto.work_schedule.PeriodListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.period_list_item, null);
    }/*  w  w w . j  a v  a 2s . c  o  m*/

    final Period period = (Period) getItem(position);

    ((TextView) convertView.findViewById(R.id.period_label)).setText(context.getString(period.getLabelId()));

    ((TextView) convertView.findViewById(R.id.period_time))
            .setText(period.formatTime(DateFormat.is24HourFormat(context)));

    CompoundButton check_alarm = (CompoundButton) convertView.findViewById(R.id.check_alarm);
    if (show_checkboxes) {
        check_alarm.setChecked(period.enabled);
        check_alarm.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View check_box) {
                boolean isChecked = ((CompoundButton) check_box).isChecked();
                period.enabled = isChecked && (period.time.getTimeInMillis() > System.currentTimeMillis());
                period.setAlarm(context, true);
                period.persist(context);
                ((CompoundButton) check_box).setChecked(period.enabled);
            }
        });
    } else {
        check_alarm.setVisibility(View.GONE);
        LinearLayout layout_labels = (LinearLayout) convertView.findViewById(R.id.layout_labels);
        LayoutParams params = (LayoutParams) layout_labels.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
        layout_labels.setLayoutParams(params);
    }

    return convertView;
}

From source file:com.openlocationcode.android.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_act);/*ww w. j  av  a2s  .  co m*/
    MyMapView myMapView = (MyMapView) findViewById(R.id.myMapView);
    mMapView = myMapView.getMapView();
    mMainPresenter = new MainPresenter(this, (SearchView) findViewById(R.id.searchView),
            (DirectionView) findViewById(R.id.directionView), (CodeView) findViewById(R.id.codeView),
            myMapView);

    mMapView.onCreate(savedInstanceState);

    // Adjust the map controls and search box top margins to account for the translucent status
    // bar.
    int statusBarHeight = getStatusBarHeight(this);
    LinearLayout mapControl = (LinearLayout) findViewById(R.id.mapControls);
    FrameLayout.LayoutParams mapParams = (FrameLayout.LayoutParams) mapControl.getLayoutParams();
    mapParams.topMargin = mapParams.topMargin + statusBarHeight;
    mapControl.setLayoutParams(mapParams);

    RelativeLayout searchBox = (RelativeLayout) findViewById(R.id.searchBox);
    FrameLayout.LayoutParams searchParams = (FrameLayout.LayoutParams) searchBox.getLayoutParams();
    searchParams.topMargin = searchParams.topMargin + statusBarHeight;
    searchBox.setLayoutParams(searchParams);

    if (getIntent() != null && Intent.ACTION_VIEW.equals(getIntent().getAction())) {
        handleGeoIntent(getIntent());
    }
}

From source file:com.thevelopment.poc.Fragments.FirstFragment.java

private LinearLayout createInnerLinearLayout(ViewGroup parentView, int width, int height) {
    LinearLayout innerLinearLayout = screenBuilder.createVerticalLinearLayout(parentView);
    RelativeLayout.LayoutParams innerLinearLayoutParams = (RelativeLayout.LayoutParams) innerLinearLayout
            .getLayoutParams();//from w w w.j  a  va2 s . co m
    innerLinearLayoutParams.setMargins(width / 20, height / 40, width / 20, height / 10);
    innerLinearLayout.setLayoutParams(innerLinearLayoutParams);
    return innerLinearLayout;
}

From source file:org.telegram.ui.Cells.UserControlCell.java

public UserControlCell(Context context, int padding) {
    super(context);

    avatarImageView = new BackupImageView(context);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
    addView(avatarImageView);//w  w  w .jav  a 2  s. c om
    LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(48);
    layoutParams.height = AndroidUtilities.dp(48);
    layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
    layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
    layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(padding) : 0;
    layoutParams.topMargin = AndroidUtilities.dp(8);
    avatarImageView.setLayoutParams(layoutParams);
    avatarDrawable = new AvatarDrawable();

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(nameTextView);
    layoutParams = (LayoutParams) nameTextView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? RIGHT_MARGIN : (68));
    layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68) : RIGHT_MARGIN);
    layoutParams.topMargin = AndroidUtilities.dp(10.5f);
    layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
    nameTextView.setLayoutParams(layoutParams);

    messageTextView = new TextView(context);
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    messageTextView.setLines(1);
    messageTextView.setMaxLines(1);
    messageTextView.setSingleLine(true);
    messageTextView.setEllipsize(TextUtils.TruncateAt.END);
    messageTextView
            .setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(messageTextView);
    layoutParams = (LayoutParams) messageTextView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? RIGHT_MARGIN : (68));
    layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (68) : RIGHT_MARGIN);
    layoutParams.topMargin = AndroidUtilities.dp(33.5f);
    layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
    messageTextView.setLayoutParams(layoutParams);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16);
    layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0);
    layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
    imageView.setLayoutParams(layoutParams);
    imageView.setVisibility(View.GONE);

    LinearLayout buttonContainer = new LinearLayout(context);
    addView(buttonContainer);
    layoutParams = (LayoutParams) buttonContainer.getLayoutParams();
    layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
    layoutParams.height = AndroidUtilities.dp(60);
    layoutParams.rightMargin = AndroidUtilities.dp(16);
    layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL;
    buttonContainer.setLayoutParams(layoutParams);

    ApproveBtn = new TextView(context);
    ApproveBtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.approve_bg));
    ApproveBtn.setTextColor(getResources().getColor(android.R.color.white));
    ApproveBtn.setText(getResources().getString(R.string.approve_join_group));
    buttonContainer.addView(ApproveBtn);
    LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ApproveBtn.getLayoutParams();
    lp.width = AndroidUtilities.dp(0);
    lp.weight = 1;
    lp.height = LayoutParams.WRAP_CONTENT;
    lp.gravity = Gravity.CENTER_VERTICAL;
    lp.rightMargin = AndroidUtilities.dp(2);
    ApproveBtn.setLayoutParams(lp);
    ApproveBtn.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8),
            AndroidUtilities.dp(8));

    IgnoreBtn = new TextView(context);
    IgnoreBtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.ignore_bg));
    IgnoreBtn.setTextColor(getResources().getColor(android.R.color.white));
    IgnoreBtn.setText(getResources().getString(R.string.ignore_join_group));
    buttonContainer.addView(IgnoreBtn);
    lp = (LinearLayout.LayoutParams) IgnoreBtn.getLayoutParams();
    lp.width = AndroidUtilities.dp(0);
    lp.weight = 1;
    lp.height = LayoutParams.WRAP_CONTENT;
    lp.gravity = Gravity.CENTER_VERTICAL;
    lp.leftMargin = AndroidUtilities.dp(2);
    IgnoreBtn.setLayoutParams(lp);
    IgnoreBtn.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8),
            AndroidUtilities.dp(8));
}

From source file:com.thevelopment.poc.Fragments.FirstFragment.java

public Spinner createTypeOfInspectionField(ViewGroup parentView, int width) {
    // CREATE TYPE OF INSPECTION LINEAR LAYOUT
    LinearLayout typeOfInspectionLinearLayout = screenBuilder.createVerticalLinearLayout(parentView,
            2 * width / 5, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams typeOfInspectionParams = (LinearLayout.LayoutParams) typeOfInspectionLinearLayout
            .getLayoutParams();//from  w w w . jav  a2 s  . co m
    typeOfInspectionParams.rightMargin = width / 10;
    typeOfInspectionLinearLayout.setLayoutParams(typeOfInspectionParams);

    // CREATE TYPE OF INSPECTION TEXT VIEW
    screenBuilder.createTextView(typeOfInspectionLinearLayout, "Tipo de Inspecao", 14);

    // CREATE TYPE OF INSPECTION SPINNER
    final Spinner typeSpinner = screenBuilder.createSpinner(typeOfInspectionLinearLayout,
            Arrays.asList(getResources().getStringArray(R.array.type_array)));

    return typeSpinner;

}