private void newHeader(final LinearLayout linearLayout, final String title) { TextView titleView = new TextView(context); titleView.setText(title); titleView.setTextSize(15); titleView.setTextColor(Color.rgb(0x10, 0x30, 0xc0)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) titleView.setPaddingRelative(40, 60, 40, 10); linearLayout.addView(titleView); }
private void setAll(FloatingMenuItem item) { mIcon.setVisibility(VISIBLE); mIcon.setImageDrawable(item.getIcon()); mText.setVisibility(VISIBLE); if (Build.VERSION.SDK_INT >= 16) mText.setPaddingRelative(mPaddingText, 0, 0, 0); else mText.setPadding(mPaddingText, 0, 0, 0); mText.setText(item.getTitle()); }
public TextView getGenericView() { // Layout parameters for the ExpandableListView AbsListView.LayoutParams lp = new AbsListView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 64); TextView textView = new TextView(ExpandableList1.this); textView.setLayoutParams(lp); // Center the text vertically textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); // Set the text starting position textView.setPaddingRelative(36, 0, 0, 0); // Set the text alignment textView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); return textView; }
public TextView getGenericView() { // Layout parameters for the ExpandableListView AbsListView.LayoutParams lp = new AbsListView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 64); TextView textView = new TextView(ExpandableList1.this); textView.setLayoutParams(lp); // Center the text vertically textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); // Set the text starting position textView.setPaddingRelative(36, 0, 0, 0); // Set the text alignment textView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); return textView; }
titleView.setTextColor(Color.BLACK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) titleView.setPaddingRelative(40, 20, 40, 3); linearLayout.addView(titleView); titleView.setPaddingRelative(40, 30, 40, 3); descView.setPaddingRelative(40, 3, 40, 20); titleView.setPaddingRelative(40, 40, 40, 40);
/** * Set the top padding on the header view dynamically, based on whether the header is in * the first row or not. */ public static void setHeaderViewBottomPadding(Context context, TextView textView, boolean isFirstRow) { final int topPadding; if (isFirstRow) { topPadding = (int) context.getResources().getDimension( R.dimen.frequently_contacted_title_top_margin_when_first_row); } else { topPadding = (int) context.getResources().getDimension( R.dimen.frequently_contacted_title_top_margin); } textView.setPaddingRelative(textView.getPaddingStart(), topPadding, textView.getPaddingEnd(), textView.getPaddingBottom()); }
ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal); activityText.setPaddingRelative(activityTextPadding, 0, activityTextPadding, 0);
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { final FavStructure fav = iList.get(position); GridLayout gridLayout = (GridLayout) holder.itemView; gridLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent mIntent = new Intent(view.getContext(), AddFavoriteActivity.class); mIntent.putExtra("id", fav._id); view.getContext().startActivity(mIntent); } }); final int valWidth = parentWidth * 2 / 3; final int nameWidth = parentWidth - valWidth; TextView valView = new TextView(gridLayout.getContext()); valView.setText(fav.value); valView.setWidth(valWidth); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) valView.setPaddingRelative(0, 0, 20, 0); gridLayout.addView(valView); TextView nameView = new TextView(gridLayout.getContext()); nameView.setText(fav.name); nameView.setWidth(nameWidth); gridLayout.addView(nameView); }
button.setWidth(size); button.setHeight(size); button.setPaddingRelative(padding, 0, padding, 0); TypedValue typedValue = new TypedValue(); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) { button.setPaddingRelative(padding, 0, padding, 0); button.setText(buttonItem.title); button.setTextColor(colorStateList);