Java Code Examples for android.widget.TextView#setMinimumWidth()

The following examples show how to use android.widget.TextView#setMinimumWidth() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Cornowser   File: TabSwitcherOpenButton.java    License: MIT License 6 votes vote down vote up
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 Project: SecondScreen   File: SeekBarPreference.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 Project: Lucid-Browser   File: SeekBarPreference.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 Project: Roundr   File: SeekBarPreference.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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
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
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 Project: TabletClock   File: TimePrefsDialogs.java    License: MIT License 4 votes vote down vote up
protected void reservePlaceForSeekBarsLevels(TextView textView) {
	Rect b = new Rect();
	textView.getPaint().getTextBounds("888", 0, 3, b);
	textView.setMinimumWidth(b.width());
}