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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations