Search in sources :

Example 66 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project vector-compat by wnafee.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Example of adding MorphButton in java
    MorphButton mb = new MorphButton(this);
    LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    mb.setLayoutParams(p);
    mb.setBackgroundTintList(getResources().getColorStateList(R.color.background_tint_color));
    mb.setForegroundTintList(getResources().getColorStateList(R.color.foreground_tint_color));
    mb.setStartDrawable(R.drawable.ic_pause_to_play);
    mb.setEndDrawable(R.drawable.ic_play_to_pause);
    mb.setOnStateChangedListener(new OnStateChangedListener() {

        @Override
        public void onStateChanged(MorphState changedTo, boolean isAnimating) {
            // Do something here
            Toast.makeText(MainActivity.this, "Changed to: " + changedTo, Toast.LENGTH_SHORT).show();
        }
    });
    LinearLayout ll = (LinearLayout) findViewById(R.id.base_view);
    ll.addView(mb);
}
Also used : OnStateChangedListener(com.wnafee.vector.MorphButton.OnStateChangedListener) LayoutParams(android.widget.LinearLayout.LayoutParams) MorphButton(com.wnafee.vector.MorphButton) MorphState(com.wnafee.vector.MorphButton.MorphState) LinearLayout(android.widget.LinearLayout)

Example 67 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project GridListViewAdapters by birajpatel.

the class BaseGridAdapter method getCardLayoutParams.

/**
     * Gets the card layout params, ie it adjust Width and left-right spacing of a
     * card.
     *
     * @param cardwidth        the cardWidth to be applied.
     * @param isLastCardInaRow boolean to check if this is last card in a row
     * @return the card layout params
     */
private LayoutParams getCardLayoutParams(int cardwidth, boolean isLastCardInaRow) {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(cardwidth, LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = CARD_SPACING;
    if (isLastCardInaRow) {
        layoutParams.rightMargin = CARD_SPACING;
    }
    return layoutParams;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) LayoutParams(android.widget.LinearLayout.LayoutParams) LinearLayout(android.widget.LinearLayout)

Example 68 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project Android-Bootstrap by Bearded-Hen.

the class BootstrapDropDown method createDropDownView.

private ScrollView createDropDownView() {
    final LinearLayout dropdownView = new LinearLayout(getContext());
    ScrollView scrollView = new ScrollView(getContext());
    int clickableChildCounter = 0;
    dropdownView.setOrientation(LinearLayout.VERTICAL);
    int height = (int) (itemHeight * bootstrapSize);
    LayoutParams childParams = new LayoutParams(LayoutParams.MATCH_PARENT, height);
    for (String text : dropdownData) {
        TextView childView = new TextView(getContext());
        childView.setGravity(Gravity.CENTER_VERTICAL);
        childView.setLayoutParams(childParams);
        int padding = (int) (baselineItemLeftPadding * bootstrapSize);
        childView.setPadding(padding, 0, padding, 0);
        childView.setTextSize(baselineDropDownViewFontSize * bootstrapSize);
        childView.setTextColor(ColorUtils.resolveColor(android.R.color.black, getContext()));
        Drawable background = getContext().obtainStyledAttributes(null, new int[] { android.R.attr.selectableItemBackground }, 0, 0).getDrawable(0);
        ViewUtils.setBackgroundDrawable(childView, background);
        childView.setTextColor(BootstrapDrawableFactory.bootstrapDropDownViewText(getContext()));
        childView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dropdownWindow.dismiss();
                if (onDropDownItemClickListener != null) {
                    onDropDownItemClickListener.onItemClick(dropdownView, v, v.getId());
                }
            }
        });
        if (Pattern.matches(SEARCH_REGEX_HEADER, text)) {
            childView.setText(text.replaceFirst(REPLACE_REGEX_HEADER, ""));
            childView.setTextSize((baselineDropDownViewFontSize - 2F) * bootstrapSize);
            childView.setClickable(false);
            childView.setTextColor(ColorUtils.resolveColor(R.color.bootstrap_gray_light, getContext()));
        } else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) {
            childView = new DividerView(getContext());
            childView.setClickable(false);
            childView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 3));
        } else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) {
            childView.setEnabled(false);
            childView.setId(clickableChildCounter++);
            childView.setText(text.replaceFirst(REPLACE_REGEX_DISABLED, ""));
        } else {
            childView.setText(text);
            childView.setId(clickableChildCounter++);
        }
        dropdownView.addView(childView);
    }
    dropdownView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    dropDownViewHeight = dropdownView.getMeasuredHeight();
    dropDownViewWidth = dropdownView.getMeasuredWidth();
    scrollView.setVerticalScrollBarEnabled(false);
    scrollView.setHorizontalScrollBarEnabled(false);
    scrollView.addView(dropdownView);
    cleanData();
    return scrollView;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) ScrollView(android.widget.ScrollView) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) BootstrapSizeView(com.beardedhen.androidbootstrap.api.view.BootstrapSizeView) OutlineableView(com.beardedhen.androidbootstrap.api.view.OutlineableView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) RoundableView(com.beardedhen.androidbootstrap.api.view.RoundableView) LinearLayout(android.widget.LinearLayout) Paint(android.graphics.Paint)

Example 69 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class LinearLayoutTest method create.

public ViewGroup create(Context context) {
    LinearLayout container = new LinearLayout(context);
    container.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
        int va = VERTICAL_ALIGNMENTS[i];
        for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
            int ha = HORIZONTAL_ALIGNMENTS[j];
            LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
            lp.gravity = va | ha;
            View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
            container.addView(v, lp);
        }
    }
    return container;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 70 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class GlyphCacheActivity method createTextView.

private TextView createTextView() {
    TextView textview = new TextView(this);
    textview.setTextSize(6 + (int) (Math.random() * 5) * 10);
    textview.setTextColor(0xff << 24 | (int) (Math.random() * 255) << 16 | (int) (Math.random() * 255) << 8 | (int) (Math.random() * 255) << 16);
    textview.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int numChars = 5 + (int) (Math.random() * 10);
    mTotalChars += numChars;
    textview.setText(createString(numChars));
    return textview;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) TextView(android.widget.TextView)

Aggregations

LayoutParams (android.widget.LinearLayout.LayoutParams)78 LinearLayout (android.widget.LinearLayout)44 View (android.view.View)36 TextView (android.widget.TextView)24 ImageView (android.widget.ImageView)17 Button (android.widget.Button)16 ProgressBar (android.widget.ProgressBar)9 Message (android.os.Message)8 OnClickListener (android.view.View.OnClickListener)8 ScrollView (android.widget.ScrollView)7 Handler (android.os.Handler)6 ViewGroup (android.view.ViewGroup)6 WebView (android.webkit.WebView)6 HorizontalScrollView (android.widget.HorizontalScrollView)5 ChangeBounds (android.transition.ChangeBounds)4 Crossfade (android.transition.Crossfade)4 Scene (android.transition.Scene)4 TransitionSet (android.transition.TransitionSet)4 SurfaceView (android.view.SurfaceView)4 TextureView (android.view.TextureView)4