Java Code Examples for android.widget.TextView#setX()
The following examples show how to use
android.widget.TextView#setX() .
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: StepsView.java From Android-StepsView with Apache License 2.0 | 6 votes |
private void drawLabels() { List<Float> indicatorPosition = mStepsViewIndicator.getThumbContainerXPosition(); if (mLabels != null) { for (int i = 0; i < mLabels.length; i++) { TextView textView = new TextView(getContext()); textView.setText(mLabels[i]); textView.setTextColor(mLabelColorIndicator); textView.setX(indicatorPosition.get(i)); textView.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); if (i <= mCompletedPosition) { textView.setTypeface(null, Typeface.BOLD); } mLabelsLayout.addView(textView); } } }
Example 2
Source File: HorizontalStepView.java From StepView with Apache License 2.0 | 5 votes |
@Override public void ondrawIndicator() { if(mTextContainer != null) { mTextContainer.removeAllViews(); List<Float> complectedXPosition = mStepsViewIndicator.getCircleCenterPointPositionList(); if(mStepBeanList != null && complectedXPosition != null && complectedXPosition.size() > 0) { for(int i = 0; i < mStepBeanList.size(); i++) { mTextView = new TextView(getContext()); mTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize); mTextView.setText(mStepBeanList.get(i).getName()); int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); mTextView.measure(spec, spec); // getMeasuredWidth int measuredWidth = mTextView.getMeasuredWidth(); mTextView.setX(complectedXPosition.get(i) - measuredWidth / 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 3
Source File: TitleBar.java From react-native-navigation with MIT License | 5 votes |
public void alignTextView(Alignment alignment, TextView view) { if (StringUtils.isEmpty(view.getText())) return; int direction = view.getParent().getLayoutDirection(); boolean isRTL = direction == View.LAYOUT_DIRECTION_RTL; if (alignment == Alignment.Center) { view.setX((getWidth() - view.getWidth()) / 2f); } else if (leftButtonController != null) { view.setX(isRTL ? (getWidth() - view.getWidth()) - getContentInsetStartWithNavigation() : getContentInsetStartWithNavigation()); } else { view.setX(isRTL ? (getWidth() - view.getWidth()) - UiUtils.dpToPx(getContext(), DEFAULT_LEFT_MARGIN) : UiUtils.dpToPx(getContext(), DEFAULT_LEFT_MARGIN)); } }
Example 4
Source File: LemonBubbleView.java From LemonBubble4Android with MIT License | 5 votes |
/** * 初始化公共的控件 */ 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 5
Source File: PopcornEditText.java From PopcornEditText with Apache License 2.0 | 5 votes |
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 6
Source File: LemonHelloView.java From LemonHello4Android with MIT License | 4 votes |
/** * 初始化公共的控件 */ 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事件容器放到内容面板中 }
Example 7
Source File: Game.java From Simple-Solitaire with GNU General Public License v3.0 | 4 votes |
/** * mirrors the textViews, if there are any. Used for left handed mode */ public void mirrorTextViews(RelativeLayout layoutGame) { for (TextView textView : textViews) { textView.setX(layoutGame.getWidth() - textView.getX() - Card.width); } }