當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.setSingleLine方法代碼示例

本文整理匯總了Java中android.widget.TextView.setSingleLine方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setSingleLine方法的具體用法?Java TextView.setSingleLine怎麽用?Java TextView.setSingleLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setSingleLine方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBindView

import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    titleView.setSingleLine(false);

    setSelectable(false);

    titleView.setClickable(true);
    titleView.setTextColor(titleView.getPaint().linkColor);
    titleView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            LearnMorePreference.this.onClick();
        }
    });
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:18,代碼來源:LearnMorePreference.java

示例2: 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

示例3: createListItem

import android.widget.TextView; //導入方法依賴的package包/類
public TextView createListItem() {
    TextView view = new TextView(mContext);
    view.setFadingEdgeLength(mFadeEdgeLength);
    view.setHorizontalFadingEdgeEnabled(true);
    view.setSingleLine();
    view.setTextSize(TEXT_SIZE_SP);
    view.setMinimumHeight(mListItemHeight);
    view.setGravity(Gravity.CENTER_VERTICAL);
    view.setCompoundDrawablePadding(mPadding);
    if (!mIsLayoutDirectionRTL) {
        view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
    } else {
        view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
    }
    return view;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:17,代碼來源:NavigationPopup.java

示例4: PhotoEditToolCell

import android.widget.TextView; //導入方法依賴的package包/類
public PhotoEditToolCell(Context context) {
    super(context);

    iconImage = new ImageView(context);
    iconImage.setScaleType(ImageView.ScaleType.CENTER);
    addView(iconImage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 12));

    nameTextView = new TextView(context);
    nameTextView.setGravity(Gravity.CENTER);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 4, 0, 4, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(0xff6cc3ff);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
    valueTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 57, 3, 0, 0));
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:24,代碼來源:PhotoEditToolCell.java

示例5: 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.setGravity(Gravity.CENTER_VERTICAL);
    textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    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.setGravity(Gravity.CENTER_VERTICAL);
    textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
    textView2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    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:pooyafaroka,項目名稱:PlusGram,代碼行數:32,代碼來源:PhotoPickerSearchCell.java

示例6: addTextTab

import android.widget.TextView; //導入方法依賴的package包/類
private void addTextTab(final int position, String title) {

        TextView tab = new TextView(getContext());
        tab.setText(title);
        tab.setGravity(Gravity.CENTER);
        tab.setSingleLine();

        addTab(position, tab);
    }
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:10,代碼來源:PagerTabStrip.java

示例7: initView

import android.widget.TextView; //導入方法依賴的package包/類
private void initView(Context context) {
    mLeftText = new TextView(context);
    mCenterLayout = new LinearLayout(context);
    mRightLayout = new LinearLayout(context);
    mDividerView = new View(context);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);

    mLeftText.setTextSize(DEFAULT_ACTION_TEXT_SIZE);
    mLeftText.setSingleLine();
    mLeftText.setGravity(Gravity.CENTER_VERTICAL);
    mLeftText.setPadding(mOutPadding + mActionPadding, 0, mOutPadding, 0);

    mCenterText = new TextView(context);
    mSubTitleText = new TextView(context);
    mCenterLayout.addView(mCenterText);
    mCenterLayout.addView(mSubTitleText);

    mCenterLayout.setGravity(Gravity.CENTER);
    mCenterText.setTextSize(DEFAULT_MAIN_TEXT_SIZE);
    mCenterText.setSingleLine();
    mCenterText.setGravity(Gravity.CENTER);
    mCenterText.setEllipsize(TextUtils.TruncateAt.END);

    mSubTitleText.setTextSize(DEFAULT_SUB_TEXT_SIZE);
    mSubTitleText.setSingleLine();
    mSubTitleText.setGravity(Gravity.CENTER);
    mSubTitleText.setEllipsize(TextUtils.TruncateAt.END);

    mRightLayout.setPadding(mOutPadding, 0, mOutPadding, 0);

    addView(mLeftText, layoutParams);
    addView(mCenterLayout);
    addView(mRightLayout, layoutParams);
    addView(mDividerView, new LayoutParams(LayoutParams.MATCH_PARENT, 1));
}
 
開發者ID:peng8350,項目名稱:JPSpringMenu,代碼行數:37,代碼來源:TitleBar.java

示例8: FriendListItem

import android.widget.TextView; //導入方法依賴的package包/類
public FriendListItem(Context context, float ratio) {
	super(context);
	int itemPadding = (int) (ratio * DESIGN_ITEM_PADDING);
	setPadding(itemPadding, 0, itemPadding, 0);
	setMinimumHeight((int) (ratio * DESIGN_ITEM_HEIGHT));
	setBackgroundColor(0xffffffff);

	ivCheck = new ImageView(context);
	LayoutParams lp = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	addView(ivCheck, lp);

	aivIcon = new AsyncImageView(context);
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avatarMargin = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.setMargins(avatarMargin, 0, avatarMargin, 0);
	addView(aivIcon, lp);

	tvName = new TextView(context);
	tvName.setTextColor(0xff000000);
	tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvName.setSingleLine();
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.weight = 1;
	addView(tvName, lp);

	int resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_check_checked");
	if (resId > 0) {
		bmChd = BitmapFactory.decodeResource(context.getResources(), resId);
	}
	resId = ResHelper.getBitmapRes(getContext(), "ssdk_oks_classic_check_default");
	if (resId > 0) {
		bmUnch = BitmapFactory.decodeResource(context.getResources(), resId);
	}
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:40,代碼來源:FriendListItem.java

示例9: onBindView

import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    if (mDrawDivider) {
        int left = view.getPaddingLeft();
        int right = view.getPaddingRight();
        int top = view.getPaddingTop();
        int bottom = view.getPaddingBottom();
        view.setBackground(DividerDrawable.create(getContext()));
        view.setPadding(left, top, right, bottom);
    }

    SwitchCompat switchView = (SwitchCompat) view.findViewById(R.id.switch_widget);
    // On BLU Life Play devices SwitchPreference.setWidgetLayoutResource() does nothing. As a
    // result, the user will see a non-material Switch and switchView will be null, hence the
    // null check below. http://crbug.com/451447
    if (switchView != null) {
        switchView.setChecked(isChecked());
    }

    TextView title = (TextView) view.findViewById(android.R.id.title);
    title.setSingleLine(false);
    if (!mDontUseSummaryAsTitle && TextUtils.isEmpty(getTitle())) {
        TextView summary = (TextView) view.findViewById(android.R.id.summary);
        title.setText(summary.getText());
        title.setVisibility(View.VISIBLE);
        summary.setVisibility(View.GONE);
    }

    if (mManagedPrefDelegate != null) mManagedPrefDelegate.onBindViewToPreference(this, view);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:33,代碼來源:ChromeSwitchPreference.java

示例10: FriendListItem

import android.widget.TextView; //導入方法依賴的package包/類
public FriendListItem(Context context, float ratio) {
	super(context);
	int itemPadding = (int) (ratio * DESIGN_ITEM_PADDING);
	setPadding(itemPadding, 0, itemPadding, 0);
	setMinimumHeight((int) (ratio * DESIGN_ITEM_HEIGHT));
	setBackgroundColor(0xffffffff);

	ivCheck = new ImageView(context);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	addView(ivCheck, lp);

	aivIcon = new AsyncImageView(context);
	int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
	lp = new LinearLayout.LayoutParams(avatarWidth, avatarWidth);
	lp.gravity = Gravity.CENTER_VERTICAL;
	int avatarMargin = (int) (ratio * DESIGN_AVATAR_PADDING);
	lp.setMargins(avatarMargin, 0, avatarMargin, 0);
	addView(aivIcon, lp);

	tvName = new TextView(context);
	tvName.setTextColor(0xff000000);
	tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvName.setSingleLine();
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.weight = 1;
	addView(tvName, lp);

	int resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_check_checked");
	if (resId > 0) {
		bmChd = BitmapFactory.decodeResource(context.getResources(), resId);
	}
	resId = ResHelper.getBitmapRes(getContext(), "ssdk_oks_classic_check_default");
	if (resId > 0) {
		bmUnch = BitmapFactory.decodeResource(context.getResources(), resId);
	}
}
 
開發者ID:6ag,項目名稱:LiuAGeAndroid,代碼行數:40,代碼來源:FriendListItem.java

示例11: addTextTab

import android.widget.TextView; //導入方法依賴的package包/類
private void addTextTab(final int position, String title) {

		TextView tab = new TextView(getContext());
		tab.setText(title);
		tab.setGravity(Gravity.CENTER);
		tab.setSingleLine();

		addTab(position, tab);
	}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:PagerSlidingTabStrip.java

示例12: init

import android.widget.TextView; //導入方法依賴的package包/類
private void init(Context context) {
    setOrientation(LinearLayout.HORIZONTAL);
    int paddingTopBottom = ConvertUtils.toPx(context, ITEM_PADDING_TOP_BOTTOM);
    int paddingLeftRight = ConvertUtils.toPx(context, ITEM_PADDING_LEFT_RIGHT);
    setPadding(paddingLeftRight, paddingTopBottom, paddingLeftRight, paddingTopBottom);
    setGravity(Gravity.CENTER);
    int height = ConvertUtils.toPx(context, ITEM_HEIGHT);
    // fixed: 17-1-8 #79 安卓4.x兼容問題,java.lang.ClassCastException……onMeasure……
    setLayoutParams(new AbsListView.LayoutParams(MATCH_PARENT, height));

    imageView = new ImageView(getContext());
    imageView.setTag(ITEM_TAG_IMAGE);
    imageView.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    imageParams.rightMargin = ConvertUtils.toPx(context, ITEM_MARGIN);
    addView(imageView, imageParams);

    textView = new TextView(getContext());
    textView.setTag(ITEM_TAG_TEXT);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setSingleLine(true);
    textView.setIncludeFontPadding(false);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    addView(textView, textParams);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:WheelListView.java

示例13: addTextTab

import android.widget.TextView; //導入方法依賴的package包/類
public void addTextTab(int position, String title) {
    TextView textTab = new TextView(getContext());
    textTab.setText(title);
    textTab.setGravity(Gravity.CENTER);
    textTab.setSingleLine();
    addTab(position, textTab);
}
 
開發者ID:JackWHLiu,項目名稱:jackknife,代碼行數:8,代碼來源:HorizontalTabBar.java

示例14: generateTitleView

import android.widget.TextView; //導入方法依賴的package包/類
private TextView generateTitleView(String title) {
    TextView tv = new TextView(getContext());
    tv.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1);
    tv.setText(title);
    tv.setLayoutParams(lp);
    tv.setOnClickListener(this);
    tv.setSingleLine();
    return tv;
}
 
開發者ID:stdnull,項目名稱:RunMap,代碼行數:11,代碼來源:PagerIndicator.java

示例15: BottomSheetCell

import android.widget.TextView; //導入方法依賴的package包/類
public BottomSheetCell(Context context, int type) {
    super(context);

    setBackgroundResource(R.drawable.list_selector);
    setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(imageView, LayoutHelper.createFrame(24, 24, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)));

    textView = new TextView(context);
    textView.setLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    if (type == 0) {
        textView.setTextColor(0xff212121);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL));
    } else if (type == 1) {
        textView.setGravity(Gravity.CENTER);
        textView.setTextColor(0xff212121);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
        textView.setTypeface(FontManager.instance().getTypeface());
        addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:28,代碼來源:BottomSheet.java


注:本文中的android.widget.TextView.setSingleLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。