本文整理匯總了Java中android.widget.TextView.setX方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setX方法的具體用法?Java TextView.setX怎麽用?Java TextView.setX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setX方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PlayerView
import android.widget.TextView; //導入方法依賴的package包/類
public PlayerView(Context context, SimpleExoPlayer player) {
super(context);
simpleExoPlayerView = new SimpleExoPlayerView(context);
progressBar = new ProgressBar(context);
textView = new TextView(context);
textView.setX(40);
textView.setY(20);
textView.setTextColor(Color.parseColor("#FFFFFF"));
textView.setTextSize(16);
textView.setText("By Herudi");
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100,100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
simpleExoPlayerView.setLayoutParams(new SimpleExoPlayerView.LayoutParams(
SimpleExoPlayerView.LayoutParams.MATCH_PARENT,
SimpleExoPlayerView.LayoutParams.MATCH_PARENT
));
setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
));
setBackgroundColor(ContextCompat.getColor(context, android.R.color.black));
addView(simpleExoPlayerView);
addView(textView);
addView(progressBar,params);
simpleExoPlayerView.setUseController(true);
simpleExoPlayerView.requestFocus();
simpleExoPlayerView.setPlayer(player);
simpleExoPlayerView.setControllerVisibilityListener(new PlaybackControlView.VisibilityListener() {
@Override
public void onVisibilityChange(int visibility) {
if (visibility==0){
textView.setVisibility(VISIBLE);
}else {
textView.setVisibility(GONE);
}
}
});
}
示例2: drawLabels
import android.widget.TextView; //導入方法依賴的package包/類
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);
}
}
}
示例3: initCountryText
import android.widget.TextView; //導入方法依賴的package包/類
private void initCountryText() {
countryAnimDuration = getResources().getInteger(R.integer.cs_labels_animation_duration);
countryOffset1 = getResources().getDimensionPixelSize(R.dimen.cs_left_offset);
countryOffset2 = getResources().getDimensionPixelSize(R.dimen.cs_card_width);
country1TextView = (TextView) findViewById(R.id.cs_tv_country_1);
country2TextView = (TextView) findViewById(R.id.cs_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"));
}
示例4: setCountryText
import android.widget.TextView; //導入方法依賴的package包/類
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();
}
示例5: initCountryText
import android.widget.TextView; //導入方法依賴的package包/類
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"));
}
示例6: initCommonView
import android.widget.TextView; //導入方法依賴的package包/類
/**
* 初始化公共的控件
*/
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事件容器放到內容麵板中
}