android.widget.TextView.setX()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中android.widget.TextView.setX()方法的一些代码示例,展示了TextView.setX()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setX()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setX

TextView.setX介绍

暂无

代码示例

代码示例来源:origin: Ramotion/cardslider-android

private void setCountryText(String text, boolean left2right) {
  final TextView invisibleText;
  final TextView visibleText;
  if (country1TextView.getAlpha() > country2TextView.getAlpha()) {
    visibleText = country1TextView;
    invisibleText = country2TextView;
  } else {
    visibleText = country2TextView;
    invisibleText = country1TextView;
  }
  final int vOffset;
  if (left2right) {
    invisibleText.setX(0);
    vOffset = countryOffset2;
  } else {
    invisibleText.setX(countryOffset2);
    vOffset = 0;
  }
  invisibleText.setText(text);
  final ObjectAnimator iAlpha = ObjectAnimator.ofFloat(invisibleText, "alpha", 1f);
  final ObjectAnimator vAlpha = ObjectAnimator.ofFloat(visibleText, "alpha", 0f);
  final ObjectAnimator iX = ObjectAnimator.ofFloat(invisibleText, "x", countryOffset1);
  final ObjectAnimator vX = ObjectAnimator.ofFloat(visibleText, "x", vOffset);
  final AnimatorSet animSet = new AnimatorSet();
  animSet.playTogether(iAlpha, vAlpha, iX, vX);
  animSet.setDuration(countryAnimDuration);
  animSet.start();
}

代码示例来源:origin: Ramotion/cardslider-android

private void initCountryText() {
  countryAnimDuration = getResources().getInteger(R.integer.labels_animation_duration);
  countryOffset1 = getResources().getDimensionPixelSize(R.dimen.left_offset);
  countryOffset2 = getResources().getDimensionPixelSize(R.dimen.card_width);
  country1TextView = (TextView) findViewById(R.id.tv_country_1);
  country2TextView = (TextView) findViewById(R.id.tv_country_2);
  country1TextView.setX(countryOffset1);
  country2TextView.setX(countryOffset2);
  country1TextView.setText(countries[0]);
  country2TextView.setAlpha(0f);
  country1TextView.setTypeface(Typeface.createFromAsset(getAssets(), "open-sans-extrabold.ttf"));
  country2TextView.setTypeface(Typeface.createFromAsset(getAssets(), "open-sans-extrabold.ttf"));
}

代码示例来源:origin: baoyachi/StepView

mTextView.setX(complectedXPosition.get(i) - measuredWidth / 2);
mTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

代码示例来源:origin: google/santa-tracker-android

@Override
  public void onAnimationUpdate(ValueAnimator valueAnimator) {
    currentScore.setX((float) valueAnimator.getAnimatedValue("x"));
    currentScore.setY((float) valueAnimator.getAnimatedValue("y"));
    currentScore.setTextSize(
        TypedValue.COMPLEX_UNIT_PX,
        (float) valueAnimator.getAnimatedValue("textSize"));
  }
},

代码示例来源:origin: google/santa-tracker-android

@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
  currentScore.setX((float) valueAnimator.getAnimatedValue("x"));
  currentScore.setY((float) valueAnimator.getAnimatedValue("y"));
  currentScore.setTextSize(

代码示例来源:origin: google/santa-tracker-android

currentScore.setX(currentScoreX);

代码示例来源:origin: wasdennnoch/AndroidN-ify

@Override
  protected void afterHookedMethod(MethodHookParam param) throws Throwable {
    mAlarmStatus.setX(0);
  }
});

代码示例来源:origin: dongorigin/AndroidDemo

@Override
  public void setX(float x) {
    super.setX(x);
//        updateTouchDelegate();
  }

代码示例来源:origin: githubwing/WingUE

@Override public void onAnimationUpdate(ValueAnimator animation) {
  Float value = (Float) animation.getAnimatedValue();
  mHintTxt.setX(value);
 }
});

代码示例来源:origin: stackoverflow.com

public Tunnel(Context context) {
   super(context);
   setOnTouchListener(this);
   TextView tv = new TextView(getContext());
   tv.setX(200);
   tv.setY(200);
   tv.setText("Text");
   TheCustomView.addView(tv);
 }

代码示例来源:origin: stackoverflow.com

public class MainActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

     LinearLayout sv = (LinearLayout)findViewById(R.id.ll);
      for(int i = 50; i < 550; i+=50){
        TextView myText = new TextView(this);
        myText.setX(i * 3);
        myText.setText("HELLLLLOOOO");
        sv.addView(myText);
      }
      }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

}

代码示例来源:origin: stackoverflow.com

protected void positionThumbLabel(SeekBar seekBar, TextView label)
{
 Rect tr = seekBar.getThumb().getBounds();
 label.setWidth(tr.width());
 label.setX(tr.left + seekBar.getPaddingLeft());
}

代码示例来源:origin: nanchen2251/CoordinatorAppBarDemo

@Override
  public boolean onDependentViewChanged(CoordinatorLayout parent, TextView child, View dependency) {
    child.setX(dependency.getX());
    child.setY(dependency.getY() + 100);
    return true;
  }
}

代码示例来源:origin: TobiasBielefeld/Simple-Solitaire

/**
 * 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);
  }
}

代码示例来源:origin: chilijung/android-stepsview

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.setTextSize(mLabelTextSize);
        textView.setGravity(Gravity.CENTER);
        textView.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        textView.measure(0, 0);
        float textWidth = textView.getMeasuredWidth();
        textView.setX(indicatorPosition.get(i) - (textWidth / 2));

        mLabelsLayout.addView(textView);
      }
    }
  }
}

代码示例来源:origin: TobiasBielefeld/Simple-Solitaire

protected void textViewPutAboveStack(int index, Stack stack){
  textViews.get(index).setX(stack.getX());
  textViews.get(index).setY(stack.getY() - textViews.get(index).getMeasuredHeight());
}

代码示例来源:origin: stackoverflow.com

view.setText("TEST");
view.setX(0);
view2.setText("TEST2");
view2.setX(0);

代码示例来源:origin: TobiasBielefeld/Simple-Solitaire

public void updateLimitedRecyclesCounter(){
  if (currentGame.hasLimitedRecycles() && !currentGame.hidesRecycleCounter()) {
    mainTextViewRecycles.setVisibility(VISIBLE);
    mainTextViewRecycles.setX(currentGame.getMainStack().getX());
    mainTextViewRecycles.setY(currentGame.getMainStack().getY());
  } else {
    mainTextViewRecycles.setVisibility(GONE);
  }
}

代码示例来源:origin: LemonITCN/LemonBubble4Android

_titleView.setX(0);
_titleView.setY(0);
_titleView.setGravity(Gravity.CENTER);

代码示例来源:origin: stackoverflow.com

TextView res;

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  final TextView img = (TextView)findViewById(R.id.second);
  res = (TextView)findViewById(R.id.first);

  img.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      img.setX(img.getX() - 5);
      changew(img.getX());
    }
  });
}

private void changew(float w){
  res.getLayoutParams().width = (int)(res.getX() +w);
  res.requestLayout();
  res.invalidate();
}

相关文章

TextView类方法