Search in sources :

Example 6 with DragShadowBuilder

use of android.view.View.DragShadowBuilder in project android_frameworks_base by AOSPA.

the class Editor method getTextThumbnailBuilder.

private DragShadowBuilder getTextThumbnailBuilder(int start, int end) {
    TextView shadowView = (TextView) View.inflate(mTextView.getContext(), com.android.internal.R.layout.text_drag_thumbnail, null);
    if (shadowView == null) {
        throw new IllegalArgumentException("Unable to inflate text drag thumbnail");
    }
    if (end - start > DRAG_SHADOW_MAX_TEXT_LENGTH) {
        final long range = getCharClusterRange(start + DRAG_SHADOW_MAX_TEXT_LENGTH);
        end = TextUtils.unpackRangeEndFromLong(range);
    }
    final CharSequence text = mTextView.getTransformedText(start, end);
    shadowView.setText(text);
    shadowView.setTextColor(mTextView.getTextColors());
    shadowView.setTextAppearance(R.styleable.Theme_textAppearanceLarge);
    shadowView.setGravity(Gravity.CENTER);
    shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    shadowView.measure(size, size);
    shadowView.layout(0, 0, shadowView.getMeasuredWidth(), shadowView.getMeasuredHeight());
    shadowView.invalidate();
    return new DragShadowBuilder(shadowView);
}
Also used : DragShadowBuilder(android.view.View.DragShadowBuilder) LayoutParams(android.view.ViewGroup.LayoutParams) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)6 DragShadowBuilder (android.view.View.DragShadowBuilder)6 LayoutParams (android.view.ViewGroup.LayoutParams)6