CandidateView.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:keepass2android 作者:
/**
 * Construct a CandidateView for showing suggested words for completion.
 * @param context
 * @param attrs
 */
public CandidateView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mSelectionHighlight = context.getResources().getDrawable(
            R.drawable.list_selector_background_pressed);

    LayoutInflater inflate =
        (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resources res = context.getResources();
    mPreviewPopup = new PopupWindow(context);
    mPreviewText = (TextView) inflate.inflate(R.layout.candidate_preview, null);
    mPreviewPopup.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    mPreviewPopup.setContentView(mPreviewText);
    mPreviewPopup.setBackgroundDrawable(null);
    mPreviewPopup.setAnimationStyle(R.style.KeyPreviewAnimation);
    mColorNormal = res.getColor(R.color.candidate_normal);
    mColorRecommended = res.getColor(R.color.candidate_recommended);
    mColorOther = res.getColor(R.color.candidate_other);
    mDivider = res.getDrawable(R.drawable.keyboard_suggest_strip_divider);
    mAddToDictionaryHint = res.getString(R.string.hint_add_to_dictionary);

    mPaint = new Paint();
    mPaint.setColor(mColorNormal);
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(mPreviewText.getTextSize());
    mPaint.setStrokeWidth(0);
    mPaint.setTextAlign(Align.CENTER);
    mDescent = (int) mPaint.descent();
    mMinTouchableWidth = (int)res.getDimension(R.dimen.candidate_min_touchable_width);

    mGestureDetector = new GestureDetector(
            new CandidateStripGestureListener(mMinTouchableWidth));
    setWillNotDraw(false);
    setHorizontalScrollBarEnabled(false);
    setVerticalScrollBarEnabled(false);
    scrollTo(0, getScrollY());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号