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


Java TextView.setGravity方法代码示例

本文整理汇总了Java中android.widget.TextView.setGravity方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setGravity方法的具体用法?Java TextView.setGravity怎么用?Java TextView.setGravity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setGravity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTextView

import android.widget.TextView; //导入方法依赖的package包/类
private void addTextView(Context context, int viewTag) {
    TextView tv = (TextView) View.inflate(context, R.layout.custom_textview, null);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParams.weight = 1.0F;

    tv.setLayoutParams(layoutParams);
    tv.setOnClickListener(this);
    tv.setGravity(Gravity.CENTER);
    if (mTextSize > 0f)
        tv.setTextSize(0, mTextSize);

    tv.setOnClickListener(this);
    tv.setTag(viewTag);
    if (viewTag == TAG_LEFT_VIEW) {
        tv.setText(mLeftText);
        mLeftTextView = tv;
    } else if (viewTag == TAG_NONE_VIEW) {
        tv.setText(mSimpleText);
        mSimpleTextView = tv;
    } else if (viewTag == TAG_RIGHT_VIEW) {
        tv.setText(mRightText);
        mRightTextView = tv;
    }
    addView(tv);
}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:26,代码来源:SubTabNavigator.java

示例2: showDialog

import android.widget.TextView; //导入方法依赖的package包/类
private void showDialog() {
    Builder builder = new Builder(this.mContext);
    TextView title = new TextView(this.mContext);
    title.setText("分享失败原因");
    title.setPadding(0, 20, 0, 20);
    title.setTextColor(-1);
    title.setGravity(17);
    title.setTextSize(16.0f);
    builder.setCustomTitle(title);
    TextView textView = new TextView(this.mContext);
    textView.setText("请添加QQ平台到SDK \n添加方式:\nUMQQSsoHandler qqSsoHandler = new UMQQSsoHandler" +
            "(getActivity(), \"你的APP ID\",\"你的APP KEY\");\nqqSsoHandler.addToSocialSDK(); " +
            "\n参考文档:\nhttp://dev.umeng" +
            ".com/social/android/share/quick-integration#social_qq_sso");
    textView.setTextColor(-1);
    textView.setTextSize(16.0f);
    textView.setAutoLinkMask(1);
    builder.setView(textView);
    builder.show().show();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:UMQQSsoHandler.java

示例3: onCreate

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (PasswordUIView.shouldUseSmartLockBranding()) {
        getActivity().setTitle(R.string.prefs_smart_lock_for_passwords);
    } else {
        getActivity().setTitle(R.string.prefs_saved_passwords);
    }
    setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getActivity()));
    mPasswordManagerHandler.addObserver(this);

    mEmptyView = new TextView(getActivity(), null);
    mEmptyView.setText(R.string.saved_passwords_none_text);
    mEmptyView.setGravity(Gravity.CENTER);
    mEmptyView.setVisibility(View.GONE);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:SavePasswordsPreferences.java

示例4: addItemView

import android.widget.TextView; //导入方法依赖的package包/类
private View addItemView(int rid, String text) {
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setId(rid);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, DensityUtil.dip2px(context, 44f)));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setBackgroundResource(R.drawable.base_item_bg_selector);
    linearLayout.setOnClickListener(this);
    TextView textView = new TextView(context);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    textView.setText(text);
    textView.setTextColor(context.getResources().getColor(R.color.bottom_dialog_textcolor));
    textView.setTextSize(16f);
    textView.setGravity(Gravity.CENTER);
    linearLayout.removeAllViews();
    linearLayout.addView(textView);
    return  linearLayout;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:18,代码来源:CustomBottomDialog.java

示例5: EmptyTextProgressView

import android.widget.TextView; //导入方法依赖的package包/类
public EmptyTextProgressView(Context context) {
    super(context);

    progressBar = new ProgressBar(context);
    progressBar.setVisibility(INVISIBLE);
    addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));

    textView = new TextView(context);
    textView.setTypeface(FontManager.instance().getTypeface());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    textView.setTextColor(0xff808080);
    textView.setGravity(Gravity.CENTER);
    textView.setVisibility(INVISIBLE);
    textView.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
    textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));

    setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:25,代码来源:EmptyTextProgressView.java

示例6: SearchButton

import android.widget.TextView; //导入方法依赖的package包/类
public SearchButton(Context context) {
    super(context);

    setBackgroundColor(0xff1a1a1a);

    selector = new View(context);
    selector.setBackgroundResource(R.drawable.list_selector);
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));

    textView1 = new TextView(context);
    textView1.setTypeface(FontManager.instance().getTypeface());
    textView1.setGravity(Gravity.CENTER_VERTICAL);
    textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView1.setTypeface(FontManager.instance().getTypeface());
    textView1.setTextColor(0xffffffff);
    textView1.setSingleLine(true);
    textView1.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 8, 4, 0));

    textView2 = new TextView(context);
    textView2.setTypeface(FontManager.instance().getTypeface());
    textView2.setGravity(Gravity.CENTER_VERTICAL);
    textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
    textView2.setTypeface(FontManager.instance().getTypeface());
    textView2.setTextColor(0xff666666);
    textView2.setSingleLine(true);
    textView2.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 26, 4, 0));
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:34,代码来源:PhotoPickerSearchCell.java

示例7: onCreateDialogView

import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected View onCreateDialogView() {
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);

    // Layout returned as dialog view
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);

    // Add text view to show the current value
    mViewValue = new TextView(mContext);
    mViewValue.setGravity(Gravity.CENTER_HORIZONTAL);
    mViewValue.setText(String.valueOf(mValue));
    layout.addView(mViewValue, params);

    // Add seek bar
    mSeekBar = new SeekBar(mContext);
    mSeekBar.setMax(mMax);
    mSeekBar.setProgress(mValue);
    // Set progress before change listener
    mSeekBar.setOnSeekBarChangeListener(this);
    layout.addView(mSeekBar, params);

    return layout;
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:27,代码来源:DialogPreferenceSeekBar.java

示例8: init

import android.widget.TextView; //导入方法依赖的package包/类
private void init(Context context) {
    if (isInEditMode()) return;
    mIndicatorView = new AVLoadingIndicatorView(context);
    mIndicatorView.setIndicatorId(AVLoadingIndicatorView.Pacman);
    mIndicatorView.setIndicatorColor(Color.WHITE);
    mIndicatorView.setId(R.id.left);
    RelativeLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(CENTER_IN_PARENT);
    addView(mIndicatorView, layoutParams);

    mText = new TextView(context);
    mText.setEms(6);
    mText.setGravity(Gravity.CENTER);
    RelativeLayout.LayoutParams textLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textLayoutParams.addRule(CENTER_IN_PARENT);
    textLayoutParams.addRule(BELOW, mIndicatorView.getId());
    addView(mText, textLayoutParams);
}
 
开发者ID:zhouphenix,项目名称:Multi-SwipeToRefreshLayout,代码行数:19,代码来源:IndicatorsRefreshHeader.java

示例9: FrameLayout

import android.widget.TextView; //导入方法依赖的package包/类
private void addIconTabBådeTekstOgBillede(final int position, int resId, String url, String title) {
  FrameLayout tabfl = new FrameLayout(getContext());
  ImageView tabi = new ImageView(getContext());
  tabi.setContentDescription(title);
  //Log.d(title+" "+resId + " Kanallogo URL="+url);
  if (resId==0) {
    Picasso.with(tabi.getContext())
            .load(url).placeholder(null)
            .into(tabi);

    tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    tabi.setAdjustViewBounds(true);
    tabi.setVisibility(View.GONE);
  } else {
    tabi.setImageResource(resId);
    tabi.setVisibility(View.INVISIBLE);
  }
  TextView tabt = new TextView(getContext());
  tabt.setText(title);
  tabt.setTypeface(App.skrift_gibson);
  tabt.setGravity(Gravity.CENTER);
  tabt.setSingleLine();

  tabfl.addView(tabi);
  tabfl.addView(tabt);

  LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
  lp.gravity=Gravity.CENTER;
  lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
  lp = (LayoutParams) tabt.getLayoutParams();
  lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
  lp.gravity=Gravity.CENTER;

  addTab(position, tabfl);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:36,代码来源:PagerSlidingTabStrip.java

示例10: getItemTextView

import android.widget.TextView; //导入方法依赖的package包/类
public static TextView getItemTextView(Context context, MenuObject menuItem, int menuItemSize,
                                       View.OnClickListener onCLick, View.OnLongClickListener onLongClick) {
    TextView itemTextView = new TextView(context);
    RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, menuItemSize);
    itemTextView.setLayoutParams(textLayoutParams);
    itemTextView.setOnClickListener(onCLick);
    itemTextView.setOnLongClickListener(onLongClick);
    itemTextView.setText(menuItem.getTitle());
    itemTextView.setPadding(0, 0, (int) context.getResources().getDimension(R.dimen.text_right_padding), 0);
    itemTextView.setGravity(Gravity.CENTER_VERTICAL);
    int textColor = menuItem.getTextColor() == 0 ?
            android.R.color.white :
            menuItem.getTextColor();

    itemTextView.setTextColor(ContextCompat.getColor(context, textColor));

    int styleResId = menuItem.getMenuTextAppearanceStyle() > 0
            ? menuItem.getMenuTextAppearanceStyle()
            : R.style.TextView_DefaultStyle;

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
        itemTextView.setTextAppearance(context, styleResId);
    } else {
        itemTextView.setTextAppearance(styleResId);
    }

    return itemTextView;
}
 
开发者ID:zongkaili,项目名称:MenuSet,代码行数:30,代码来源:Utils.java

示例11: getLoadingView

import android.widget.TextView; //导入方法依赖的package包/类
private View getLoadingView() {
    TextView tv = new TextView(this);
    tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    tv.setText("Helper中定义的加载中");
    tv.setGravity(Gravity.CENTER);
    tv.setTextSize(18);
    tv.setTextColor(Color.RED);
    // 设置tag为loading
    tv.setTag(StatusLayout.Status.LOADING.getStatus());
    return tv;
}
 
开发者ID:yhyzgn,项目名称:Widgets,代码行数:12,代码来源:HelperActivity.java

示例12: setSpinnerText

import android.widget.TextView; //导入方法依赖的package包/类
private void setSpinnerText(View view) {
    view.setBackgroundColor(getResources().getColor(R.color.in));
    TextView textView = (TextView) view;
    textView.setTextColor(getResources().getColor(R.color.ax));
    textView.setTextSize(16.0f);
    textView.setGravity(19);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:MeasureCurveActivity.java

示例13: init

import android.widget.TextView; //导入方法依赖的package包/类
/**
 *
 */
private void init() {

    int dip2px = DensityUtil.dip2px(2.0F);

    padding = getResources().getDimensionPixelSize(R.dimen.SmallestPadding);
    TextView description = new TextView(getContext());
    description.setSingleLine();
    description.setEllipsize(TextUtils.TruncateAt.END);
    description.setTextColor(getResources().getColor(R.color.ccp_green));
    description.setTextSize(TypedValue.COMPLEX_UNIT_PX , getResources().getDimensionPixelSize(R.dimen.HintTextSize) + dip2px);
    description.setText(R.string.tab_view_name);
    description.setTypeface(null, Typeface.NORMAL);
    addView(mTabDescription = description);

    ImageView descriptionImage = new ImageView(getContext());
    descriptionImage.setImageResource(R.drawable.unread_dot);
    descriptionImage.setVisibility(View.INVISIBLE);
    addView(mTabImage = descriptionImage);

    TextView tips = new TextView(getContext());
    tips.setTextColor(getResources().getColor(android.R.color.white));
    tips.setTextSize(0, getResources().getDimensionPixelSize(R.dimen.SmallestTextSize));
    tips.setBackgroundResource(R.drawable.to_read_tips_onbackbtn);
    tips.setGravity(Gravity.CENTER);
    tips.setVisibility(View.INVISIBLE);

    addView(mTabUnreadTips = tips);

    setBackgroundResource(R.drawable.tab_item_bg);

}
 
开发者ID:NewCasino,项目名称:browser,代码行数:35,代码来源:CCPTabView.java

示例14: configureTextView

import android.widget.TextView; //导入方法依赖的package包/类
/**
     * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
     * @param view the text view to be configured
     */
    protected void configureTextView(TextView view) {
        view.setTextColor(textColor);
        view.setGravity(Gravity.CENTER);
        view.setTextSize(textSize);
        view.setEllipsize(TextUtils.TruncateAt.END);
        view.setLines(1);
//        view.setCompoundDrawablePadding(20);
//        view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    }
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:14,代码来源:AbstractWheelTextAdapter.java

示例15: addTextTab

import android.widget.TextView; //导入方法依赖的package包/类
private void addTextTab(final int position, String title) {
    View layoutView = View.inflate(getContext(), R.layout.layout_tv, null);
    TextView tab = (TextView) layoutView.findViewById(R.id.tv_content);
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    addTab(position, tab, layoutView);
}
 
开发者ID:q805699513,项目名称:PagerSlidingTabStrip,代码行数:9,代码来源:PagerSlidingTabStrip.java


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