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

The following examples show how to use android.widget.TextView#setY() . 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: VerticalStepView.java    From StepView with Apache License 2.0 5 votes vote down vote up
@Override
public void ondrawIndicator()
{
    if(mTextContainer != null)
    {
        mTextContainer.removeAllViews();//clear ViewGroup
        List<Float> complectedXPosition = mStepsViewIndicator.getCircleCenterPointPositionList();
        if(mTexts != null && complectedXPosition != null && complectedXPosition.size() > 0)
        {
            for(int i = 0; i < mTexts.size(); i++)
            {
                mTextView = new TextView(getContext());
                mTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize);
                mTextView.setText(mTexts.get(i));
                mTextView.setY(complectedXPosition.get(i) - mStepsViewIndicator.getCircleRadius() / 2);
                mTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

                if(i <= mComplectingPosition)
                {
                    mTextView.setTypeface(null, Typeface.BOLD);
                    mTextView.setTextColor(mComplectedTextColor);
                } else
                {
                    mTextView.setTextColor(mUnComplectedTextColor);
                }

                mTextContainer.addView(mTextView);
            }
        }
    }
}
 
Example 2
Source File: LemonBubbleView.java    From LemonBubble4Android with MIT License 5 votes vote down vote up
/**
 * 初始化公共的控件
 */
private void initCommonView() {
    // 实例化灰色半透明蒙版控件
    _backMaskView = new View(_context);
    _backMaskView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (_currentBubbleInfo.getOnMaskTouchContext() != null)
                _currentBubbleInfo.getOnMaskTouchContext().onTouch(_currentBubbleInfo, LemonBubbleView.this);
        }
    });
    // 设置全屏宽
    _backMaskView.setLayoutParams(new RelativeLayout.LayoutParams(_PST.dpToPx(_PST.screenWidthDp()), _PST.dpToPx(_PST.screenHeightDp())));
    _rootLayout.setAlpha(0);// 设置全透明,也就是默认不可见,后期通过动画改变来显示

    // 实例化内容面板控件
    _contentPanel = new RelativeLayout(_context);
    _contentPanel.setX(_PST.dpToPx((int) (_PST.screenWidthDp() / 2.0)));
    _contentPanel.setY(_PST.dpToPx((int) (_PST.screenHeightDp() / 2.0)));

    // 实例化绘图动画和帧图片显示的控件
    _paintView = new LemonBubblePaintView(_context);

    // 实例化标题显示标签控件
    _titleView = new TextView(_context);
    _titleView.setX(0);
    _titleView.setY(0);
    _titleView.setGravity(Gravity.CENTER);

    // 把所有控件添加到根视图上
    _rootLayout.addView(_backMaskView);// 半透明灰色背景
    _rootLayout.addView(_contentPanel);// 主内容面板
    _contentPanel.addView(_paintView);// 动画和帧图标显示控件放置到内容面板上
    _contentPanel.addView(_titleView);// 标题显示标签控件放置到内容面板上

}
 
Example 3
Source File: PopcornEditText.java    From PopcornEditText with Apache License 2.0 5 votes vote down vote up
private void fire(Character c) {
    final TextView textView = new TextView(getContext());
    textView.setText(c.toString());
    textView.setTextColor(mPopcornColor);
    textView.setTextSize(mPopcornSize);

    final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    content.addView(textView, params);

    startX = getLayout().getPrimaryHorizontal(getSelectionStart());
    startY = getRootView().getHeight();

    textView.setX(startX);
    textView.setY(startY);
    textView.animate().translationY(mEndY)
            .setInterpolator(new DecelerateInterpolator())
            .withEndAction(new Runnable() {
                @Override
                public void run() {
                    content.removeView(textView);
                    physicsLayout.addView(textView);
                    postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            physicsLayout.removeView(textView);
                        }
                    }, mTTL);
                }
            })
            .start();
}
 
Example 4
Source File: MainActivity.java    From SchoolTimetable with MIT License 5 votes vote down vote up
private TextView createTv(int start,int end,String text){
    TextView tv = new TextView(this);
    /*
     指定高度和宽度
     */
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(gridWidth,gridHeight*(end-start+1));
    /*
    指定位置
     */
    tv.setY(gridHeight*(start-1));
    tv.setLayoutParams(params);
    tv.setGravity(Gravity.CENTER);
    tv.setText(text);
    return tv;
}
 
Example 5
Source File: LemonHelloView.java    From LemonHello4Android with MIT License 4 votes vote down vote up
/**
 * 初始化公共的控件
 */
private void initCommonView() {
    // 实例化灰色半透明蒙版控件
    _backMaskView = new View(_context);
    _backMaskView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (_currentInfo.getEventDelegate() != null)
                _currentInfo.getEventDelegate().onMaskTouch(LemonHelloView.this, _currentInfo);
        }
    });
    // 设置全屏宽
    _backMaskView.setLayoutParams(new RelativeLayout.LayoutParams(_PST.dpToPx(_PST.screenWidthDp()), _PST.dpToPx(_PST.screenHeightDp())));
    _rootLayout.setAlpha(0);// 设置全透明,也就是默认不可见,后期通过动画改变来显示

    // 实例化内容面板控件
    _contentPanel = new LemonHelloPanel(_context);
    _contentPanel.setX(_PST.dpToPx((int) (_PST.screenWidthDp() / 2.0)));
    _contentPanel.setY(_PST.dpToPx((int) (_PST.screenHeightDp() / 2.0)));

    // 实例化内容面板控件的布局
    _contentLayout = new RelativeLayout(_context);

    // 实例化绘图动画和帧图片显示的控件
    _paintView = new LemonPaintView(_context);

    // 实例化标题显示标签控件
    _titleView = new TextView(_context);
    _titleView.setX(0);
    _titleView.setY(0);
    _titleView.setGravity(Gravity.CENTER);

    _contentView = new TextView(_context);
    _contentView.setX(0);
    _contentView.setY(0);
    _contentView.setGravity(Gravity.CENTER);

    _actionContainer = new RelativeLayout(_context);
    _actionContainer.setX(0);
    _actionContainer.setY(0);

    _contentView.setAlpha(0);
    _titleView.setAlpha(0);
    _contentPanel.setAlpha(0);

    // 把所有控件添加到根视图上
    _rootLayout.addView(_backMaskView);// 半透明灰色背景
    _rootLayout.addView(_contentPanel);// 主内容面板
    _contentPanel.addView(_contentLayout);
    _contentLayout.addView(_paintView);// 动画和帧图标显示控件放置到内容面板上
    _contentLayout.addView(_titleView);// 标题显示标签控件放置到内容面板上
    _contentLayout.addView(_contentView);// 正文内容显示标签控件放到内容面板上
    _contentLayout.addView(_actionContainer);// action事件容器放到内容面板中
}