Android Layout - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Layout class.

This code example shows how to use the following methods: setColor, setShadowLayer, setTextSize, setTypeface, getDesiredWidth
		if (valuePaint == null) {
			if (typefaceWeight == Typeface.BOLD) {
				valuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG
						| Paint.FAKE_BOLD_TEXT_FLAG | Paint.DITHER_FLAG);
			} else { 
				valuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG
						| Paint.DITHER_FLAG);
			} 
			//valuePaint.density = getResources().getDisplayMetrics().density; 
			valuePaint.setTextSize(textSize);
			valuePaint.setShadowLayer(0.5f, 0, 0.5f, 0xFFFFFFFF);
			valuePaint.setTypeface(typeface);
			valuePaint.setColor((textColor == NOVAL) ? ITEMS_TEXT_COLOR : textColor);
		} 
 
		if (centerDrawable == null) {
			centerDrawable = getWheelValDrawable(); //getContext().getResources().getDrawable(R.drawable.wheel_val);
		} 
 
		if (topShadow == null) {

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setAlpha, setAntiAlias, setTextSize, setTypeface, getDesiredWidth
    ++n;
    return (n <= 0) ? 1 : n;
  } 
 
  private void prepareLayout() { 
    float desiredWidth = Layout.getDesiredWidth(text, paint);
 
    textWidth = (int)Math.ceil(desiredWidth);
    if (textWidth > maxWidthPixels) {
      textWidth = maxWidthPixels;
    } 
    else if (textWidth <= 0) {
      textWidth = 1;
    } 
 
    Layout.Alignment _alignment = Layout.Alignment.ALIGN_NORMAL;
 
    if (alignment == 1) {
      _alignment = Layout.Alignment.ALIGN_CENTER;
    } 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getLineForVertical, getOffsetForHorizontal
 
			x += widget.getScrollX();
			y += widget.getScrollY();
 
			Layout layout = widget.getLayout();
			int line = layout.getLineForVertical(y);
			int off = layout.getOffsetForHorizontal(line, x);
 
			ClickableSpan[] links = buffer.getSpans(off, off,
					ClickableSpan.class);
 
			if (links.length != 0 && links[0] instanceof URLSpan) {
				HashMap args = new HashMap();
				args.put("url", ((URLSpan) links[0]).getURL());
				_proxy.fireEvent("click", args);
				return true; 
			} 
		} 
		return super.onTouchEvent(widget, buffer, event);
	} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: draw, getLineCount
	private int getTextLineCount(CharSequence source, TextPaint paint, int widthPx, float textSize) {
		// Update the text paint object 
		paint.setTextSize(textSize);
 
		// Draw using a static layout 
		StaticLayout layout = new StaticLayout(source, paint, widthPx, Alignment.ALIGN_NORMAL, mSpacingMult,
				mSpacingAdd, true);
		layout.draw(TEXT_RESIZE_CANVAS);
 
		return layout.getLineCount();
	} 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: draw, getEllipsizedWidth, getHeight
mTextPaint.drawableState = getDrawableState();
 
        Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
 
        canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getEllipsizedWidth() / 2,
                (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
        switchText.draw(canvas);
 
        canvas.restore();
    } 
 
    @Override 
    public int getCompoundPaddingRight() { 
        int padding = super.getCompoundPaddingRight() + mSwitchWidth;
        if (!TextUtils.isEmpty(getText())) {
            padding += mSwitchPadding;
        } 
        return padding;
    } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Layout Questions & Answers:

See Code Examples for Android Layout Methods: