当前位置: 首页>>代码示例>>Java>>正文


Java TextView.setX方法代码示例

本文整理汇总了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);
            }
        }
    });
}
 
开发者ID:herudi,项目名称:react-native-exoplayer-intent-video,代码行数:39,代码来源:PlayerView.java

示例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);
        }
    }
}
 
开发者ID:Canner,项目名称:android-stepsview,代码行数:22,代码来源:StepsView.java

示例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"));
}
 
开发者ID:Ramotion,项目名称:showroom-android,代码行数:16,代码来源:CardSliderActivity.java

示例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();
}
 
开发者ID:Ramotion,项目名称:showroom-android,代码行数:33,代码来源:CardSliderActivity.java

示例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"));
}
 
开发者ID:Ramotion,项目名称:cardslider-android,代码行数:16,代码来源:MainActivity.java

示例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事件容器放到内容面板中
}
 
开发者ID:LemonAppCN,项目名称:LemonHello4Android,代码行数:57,代码来源:LemonHelloView.java


注:本文中的android.widget.TextView.setX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。