Java Code Examples for android.widget.TextView#setMinimumWidth()
The following examples show how to use
android.widget.TextView#setMinimumWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabSwitcherOpenButton.java From Cornowser with MIT License | 6 votes |
public void init(Context context) { if (myContext == null) myContext = context; if(CornBrowser.getContext() != null) { pressedColor = ContextCompat.getColor(CornBrowser.getContext(), R.color.dark_semi_more_transparent); setGravity(Gravity.CENTER); ImageView img = new ImageView(getContext()); img.setImageResource(R.drawable.omnibox_tabswitch_icon); addView(img); TextView t = new TextView(getContext()); t.setTextSize(14f); t.setGravity(Gravity.CENTER); t.setMinimumWidth(getWidth()); t.setTextColor(Color.BLACK); addView(t); t.bringToFront(); setTabCount(0); setOnTouchListener(new PressHoverTouchListener(Color.TRANSPARENT, pressedColor)); } }
Example 2
Source File: SeekBarPreference.java From SecondScreen with Apache License 2.0 | 6 votes |
/** * Update a SeekBarPreference view with our current state * @param view */ protected void updateView(View view) { try { mStatusText = (TextView) view.findViewById(R.id.seekBarPrefValue); mStatusText.setText(String.valueOf(mCurrentValue)); mStatusText.setMinimumWidth(30); mSeekBar.setProgress(mCurrentValue - mMinValue); TextView unitsRight = (TextView)view.findViewById(R.id.seekBarPrefUnitsRight); unitsRight.setText(mUnitsRight); TextView unitsLeft = (TextView)view.findViewById(R.id.seekBarPrefUnitsLeft); unitsLeft.setText(mUnitsLeft); } catch(Exception e) { Log.e(TAG, "Error updating seek bar preference", e); } }
Example 3
Source File: SeekBarPreference.java From Lucid-Browser with Apache License 2.0 | 6 votes |
/** * Update a SeekBarPreference view with our current state * @param view */ protected void updateView(View view) { try { mStatusText = (TextView) view.findViewById(R.id.seekBarPrefValue); mStatusText.setText(String.valueOf(mCurrentValue)); mStatusText.setMinimumWidth(30); mSeekBar.setProgress(mCurrentValue - mMinValue); TextView unitsRight = (TextView)view.findViewById(R.id.seekBarPrefUnitsRight); unitsRight.setText(mUnitsRight); TextView unitsLeft = (TextView)view.findViewById(R.id.seekBarPrefUnitsLeft); unitsLeft.setText(mUnitsLeft); } catch(Exception e) { Log.e(TAG, "Error updating seek bar preference", e); } }
Example 4
Source File: SeekBarPreference.java From Roundr with Apache License 2.0 | 6 votes |
/** * Update a SeekBarPreference view with our current state * * @param view */ protected void updateView(View view) { try { RelativeLayout layout = (RelativeLayout) view; mStatusText = (TextView) layout.findViewById(R.id.seekBarPrefValue); mStatusText.setText(String.valueOf(pxFromDp(mCurrentValue))); mStatusText.setMinimumWidth(30); mSeekBar.setProgress(mCurrentValue - mMinValue); } catch (Exception e) { Log.e(TAG, "Error updating seek bar preference", e); } }
Example 5
Source File: SeekBarPreference.java From SimplePomodoro-android with MIT License | 6 votes |
/** * Update a SeekBarPreference view with our current state * @param view */ protected void updateView(View view) { try { mStatusText = (TextView) view.findViewById(R.id.seekBarPrefValue); mStatusText.setText(String.valueOf(mCurrentValue)); mStatusText.setMinimumWidth(30); mSeekBar.setProgress(mCurrentValue - mMinValue); TextView unitsRight = (TextView)view.findViewById(R.id.seekBarPrefUnitsRight); unitsRight.setText(mUnitsRight); TextView unitsLeft = (TextView)view.findViewById(R.id.seekBarPrefUnitsLeft); unitsLeft.setText(mUnitsLeft); } catch(Exception e) { Log.e(TAG, "Error updating seek bar preference", e); } }
Example 6
Source File: SeekBarPreference.java From ploggy with GNU General Public License v3.0 | 6 votes |
/** * Update a SeekBarPreference view with our current state * @param view */ protected void updateView(View view) { try { mStatusText = (TextView) view.findViewById(R.id.seekBarPrefValue); mStatusText.setText(String.valueOf(mCurrentValue)); mStatusText.setMinimumWidth(30); mSeekBar.setProgress(mCurrentValue - mMinValue); TextView unitsRight = (TextView)view.findViewById(R.id.seekBarPrefUnitsRight); unitsRight.setText(mUnitsRight); TextView unitsLeft = (TextView)view.findViewById(R.id.seekBarPrefUnitsLeft); unitsLeft.setText(mUnitsLeft); } catch(Exception e) { Log.e(TAG, "Error updating seek bar preference", e); } }
Example 7
Source File: TextViewUtil.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Sets the minimum width of a text view. * * @param textview text view instance * @param minWidth minimum width of the text view in pixels */ public static void setMinWidth(TextView textview, int minWidth) { // According to https://developer.android.com/reference/android/widget/TextView.html#setMinWidth(int), the minimum // width of TextView is the maximum of setMinWidth and setMinimumWidth. Talk about NIH syndrome! textview.setMinWidth(minWidth); textview.setMinimumWidth(minWidth); }
Example 8
Source File: TimePickerClockDelegate.java From DateTimePicker with Apache License 2.0 | 5 votes |
/** * Ensures that a TextView is wide enough to contain its text without * wrapping or clipping. Measures the specified view and sets the minimum * width to the view's desired width. * * @param v the text view to measure */ private static void ensureMinimumTextWidth(TextView v) { v.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); // Set both the TextView and the View version of minimum // width because they are subtly different. final int minWidth = v.getMeasuredWidth(); v.setMinWidth(minWidth); v.setMinimumWidth(minWidth); }
Example 9
Source File: TokenCompleteTextView.java From SocialTokenAutoComplete with Apache License 2.0 | 5 votes |
public CountSpan(int count, Context ctx, int textColor, int textSize, int maxWidth) { super(new TextView(ctx)); TextView v = (TextView)view; v.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); v.setTextColor(textColor); v.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); //Make the view as wide as the parent to push the tokens off screen v.setMinimumWidth(maxWidth); setCount(count); }
Example 10
Source File: ViewMaker.java From iGap-Android with GNU Affero General Public License v3.0 | 4 votes |
static View getViewForward() { LinearLayout cslr_ll_forward = new LinearLayout(context); cslr_ll_forward.setId(R.id.cslr_ll_forward); cslr_ll_forward.setClickable(true); cslr_ll_forward.setOrientation(HORIZONTAL); cslr_ll_forward.setPadding(i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding), i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { cslr_ll_forward.setTextDirection(View.TEXT_DIRECTION_LOCALE); } setLayoutDirection(cslr_ll_forward, View.LAYOUT_DIRECTION_LOCALE); LinearLayout.LayoutParams layout_687 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); cslr_ll_forward.setLayoutParams(layout_687); View View_997 = new View(context); View_997.setBackgroundColor(Color.parseColor(G.textBubble)); LinearLayout.LayoutParams layout_547 = new LinearLayout.LayoutParams(dpToPixel(2), ViewGroup.LayoutParams.MATCH_PARENT); layout_547.rightMargin = dpToPixel(3); View_997.setLayoutParams(layout_547); cslr_ll_forward.addView(View_997); TextView cslr_txt_prefix_forward = new TextView(context); cslr_txt_prefix_forward.setId(R.id.cslr_txt_prefix_forward); cslr_txt_prefix_forward.setText(context.getResources().getString(R.string.forwarded_from)); cslr_txt_prefix_forward.setTextColor(Color.parseColor(G.textBubble)); setTextSize(cslr_txt_prefix_forward, R.dimen.dp12); cslr_txt_prefix_forward.setSingleLine(true); cslr_txt_prefix_forward.setTypeface(G.typeface_IRANSansMobile_Bold); LinearLayout.LayoutParams layout_992 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layout_992.rightMargin = i_Dp(dp4); layout_992.leftMargin = i_Dp(R.dimen.dp6); cslr_txt_prefix_forward.setLayoutParams(layout_992); cslr_ll_forward.addView(cslr_txt_prefix_forward); TextView cslr_txt_forward_from = new TextView(context); cslr_txt_forward_from.setId(R.id.cslr_txt_forward_from); cslr_txt_forward_from.setMinimumWidth(i_Dp(R.dimen.dp100)); cslr_txt_forward_from.setMaxWidth(i_Dp(R.dimen.dp140)); cslr_txt_forward_from.setTextColor(Color.parseColor(G.textBubble)); setTextSize(cslr_txt_forward_from, R.dimen.dp12); cslr_txt_forward_from.setSingleLine(true); cslr_txt_forward_from.setTypeface(G.typeface_IRANSansMobile_Bold); LinearLayout.LayoutParams layout_119 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); cslr_txt_forward_from.setLayoutParams(layout_119); cslr_ll_forward.addView(cslr_txt_forward_from); return cslr_ll_forward; }
Example 11
Source File: TimePrefsDialogs.java From TabletClock with MIT License | 4 votes |
protected void reservePlaceForSeekBarsLevels(TextView textView) { Rect b = new Rect(); textView.getPaint().getTextBounds("888", 0, 3, b); textView.setMinimumWidth(b.width()); }