public DrawerProfileCell(Context context) { super(context); setBackgroundColor(0xff4c84b5); shadowView = new ImageView(context); shadowView.setVisibility(INVISIBLE); shadowView.setScaleType(ImageView.ScaleType.FIT_XY); shadowView.setImageResource(R.drawable.bottom_shadow); addView( shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, Gravity.LEFT | Gravity.BOTTOM)); avatarImageView = new BackupImageView(context); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32)); addView( avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67)); nameTextView = new TextView(context); nameTextView.setTextColor(0xffffffff); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setLines(1); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setGravity(Gravity.LEFT); addView( nameTextView, LayoutHelper.createFrame( LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 16, 28)); phoneTextView = new TextView(context); phoneTextView.setTextColor(0xffc2e5ff); phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); phoneTextView.setLines(1); phoneTextView.setMaxLines(1); phoneTextView.setSingleLine(true); phoneTextView.setGravity(Gravity.LEFT); addView( phoneTextView, LayoutHelper.createFrame( LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 16, 9)); }
public TextDetailCell(Context context) { super(context); textView = new MyTextView(context); textView.setTextColor(0xff212121); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView( textView, LayoutHelper.createFrame( LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 16 : 71, 10, LocaleController.isRTL ? 71 : 16, 0)); valueTextView = new MyTextView(context); valueTextView.setTextColor(0xff8a8a8a); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView( valueTextView, LayoutHelper.createFrame( LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 16 : 71, 35, LocaleController.isRTL ? 71 : 16, 0)); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); addView( imageView, LayoutHelper.createFrame( LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 0 : 16, 0, LocaleController.isRTL ? 16 : 0, 0)); }
public TextColorCell(Context context) { super(context); if (paint == null) { paint = new Paint(); paint.setColor(0xffd9d9d9); paint.setStrokeWidth(1); } colorDrawable = getResources().getDrawable(R.drawable.switch_to_on2); textView = new MyTextView(context); textView.setTextColor(0xff212121); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setGravity( (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView( textView, LayoutHelper.createFrame( LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ButterKnife.bind(this); mContext = this; mUrl = getIntent().getStringExtra(EXTRA_URL); mTitle = getIntent().getStringExtra(EXTRA_TITLE); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setLoadWithOverviewMode(true); settings.setAppCacheEnabled(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setSupportZoom(true); mWebView.setWebChromeClient(new ChromeClient()); mWebView.setWebViewClient(new LoveClient()); mWebView.loadUrl(mUrl); mTextSwitcher.setFactory( () -> { TextView textView = new TextView(this); textView.setTextAppearance(this, R.style.WebTitle); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.MARQUEE); textView.postDelayed(() -> textView.setSelected(true), 1738); return textView; }); mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); if (mTitle != null) setTitle(mTitle); }
public AttachButton(Context context) { super(context); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); addView(imageView, LayoutHelper.createFrame(64, 64, Gravity.CENTER_HORIZONTAL | Gravity.TOP)); textView = new TextView(context); textView.setLines(1); textView.setSingleLine(true); textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextColor(0xff757575); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); addView( textView, LayoutHelper.createFrame( LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 64, 0, 0)); }
public TiUIProgressBar(final TiViewProxy proxy) { super(proxy); view = new LinearLayout(proxy.getActivity()) { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); TiUIHelper.firePostLayoutEvent(proxy); } }; view.setOrientation(LinearLayout.VERTICAL); label = new TextView(proxy.getActivity()); label.setGravity(Gravity.TOP | Gravity.LEFT); label.setPadding(0, 0, 0, 0); label.setSingleLine(false); progress = new ProgressBar(proxy.getActivity(), null, android.R.attr.progressBarStyleHorizontal); progress.setIndeterminate(false); progress.setMax(1000); view.addView(label); view.addView(progress); setNativeView(view); }
private void addTab(@NonNull List<String> tabTexts, int i) { final TextView tab = new TextView(getContext()); tab.setSingleLine(); tab.setEllipsize(TextUtils.TruncateAt.END); tab.setGravity(Gravity.CENTER); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, menuTextSize); tab.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f)); tab.setTextColor(textUnselectedColor); tab.setCompoundDrawablesWithIntrinsicBounds( null, null, getResources().getDrawable(menuUnselectedIcon), null); tab.setText(tabTexts.get(i)); tab.setPadding(dpTpPx(5), dpTpPx(12), dpTpPx(5), dpTpPx(12)); // 添加点击事件 tab.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { switchMenu(tab); if (mDropDownMenuListener != null) mDropDownMenuListener.onClickListener(v); } }); tabMenuView.addView(tab); // 添加分割线 if (i < tabTexts.size() - 1) { View view = new View(getContext()); view.setLayoutParams(new LayoutParams(dpTpPx(0.5f), ViewGroup.LayoutParams.MATCH_PARENT)); view.setBackgroundColor(dividerColor); tabMenuView.addView(view); } }
@Override public void setSingleLine(final boolean singleLine) { super.setSingleLine(singleLine); if (singleLine) _maxLines = 1; else _maxLines = NO_LINE_LIMIT; reAdjust(); }
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); }
/** * onCreate之后调用,可以用来初始化view * * @param savedInstanceState the saved instance state */ @Override public final void onCreateAfter(Bundle savedInstanceState) { parseIntent(); enableJavascript(); enableCaching(); enableClient(); enableAdjust(); zoomedOut(); // 网页标题 mTextSwitcher.setFactory( () -> { TextView textView = new TextView(this); textView.setTextAppearance(this, R.style.WebTitle); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.MARQUEE); textView.postDelayed(() -> textView.setSelected(true), 1738); return textView; }); mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); if (title != null) setTitle(title); if (mProgressBar != null) mProgressBar.setReachedBarColor(BaseApplication.color(R.color.colorPrimary)); // 设置滑动监听 mWebView.setOnScrollChangedCallback( (dx, dy, x, y) -> { // 滑动监听 }); onCreateAfterLater(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View row = null; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.file_picker_list_item, parent, false); } else { row = convertView; } File object = mObjects.get(position); ImageView imageView = (ImageView) row.findViewById(R.id.file_picker_image); TextView textView = (TextView) row.findViewById(R.id.file_picker_text); // Set single line textView.setSingleLine(true); textView.setText(object.getName()); if (object.isFile()) { // Show the file icon imageView.setImageResource(R.drawable.file); } else { // Show the folder icon imageView.setImageResource(R.drawable.folder); } return row; }
public void setData(SpecialDetailData item, boolean isShowHeader) { TextViewUtil.setDisplayModel(getContext(), mHeader, mTitle, mDesc, item.isRead()); mTitle.setSingleLine(false); mTitle.setMaxLines(2); mTitle.setTextSize(NewItem.getTitleTextSize()); mTitle.setText(item.getTitle()); mDesc.setText(item.getFriendTime()); if ("1".equals(item.getIscomment())) { mComment.setVisibility(View.GONE); } else { String com = (!TextUtils.isEmpty(item.getCommentcount()) && Integer.parseInt(item.getCommentcount()) >= Constants.NEWS_LIST_SHOW_COMMENT_NUMBER_LOWER_BOUND) ? String.format( getString(R.string.comment_count_string_format), item.getCommentcount()) : null; mComment.setText(com); } mAction.setVisibility(View.GONE); if (isShowHeader) { mHeader.setVisibility(View.VISIBLE); mHeader.setText(item.getGrouptitle()); } else { mHeader.setVisibility(View.GONE); } }
private void addIconTabBådeTekstOgBillede( final int position, int resId, Bitmap res, String title) { FrameLayout tabfl = new FrameLayout(getContext()); if (Build.VERSION.SDK_INT > 11) tabfl.setLayoutTransition(new LayoutTransition()); ImageView tabi = new ImageView(getContext()); tabi.setContentDescription(title); if (res != null) { tabi.setImageBitmap(res); tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE); tabi.setAdjustViewBounds(true); } else { tabi.setImageResource(resId); } tabi.setVisibility(View.GONE); 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 = (LayoutParams) tabt.getLayoutParams(); lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT; lp.gravity = Gravity.CENTER; addTab(position, tabfl); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = (LayoutInflater) currentActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.main_inputs_history_singlerow, parent, false); } final File file = (File) getItem(position); TextView fileName = (TextView) convertView.findViewById(R.id.savedInputFileName); CheckBox inputHisCheckbox = (CheckBox) convertView.findViewById(R.id.savedInputCheckBox); inputHisCheckbox.setChecked(checkboxesStates.get(position)); inputHisCheckbox.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { int fileIndex = mFiles.indexOf(file); if (isChecked) { // set check box states in the state collection checkboxesStates.set(fileIndex, true); selectedInputs.add(file); if (mActionMode == null) { mActionMode = currentActivity.startActionMode(mActionModeCallback); } } else { if (fileIndex > -1) { checkboxesStates.set(fileIndex, false); } selectedInputs.remove(file); if (selectedInputs.size() < 1) { mActionMode.finish(); mActionMode = null; } } } }); fileName.setSingleLine(true); fileName.setText(file.getName().split("\\.")[0]); convertView.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { String message = null; try { message = readFile(file); } catch (IOException e) { e.printStackTrace(); message = "Fail to read saved input."; } MessageHelper.showMessageDialog(currentActivity, "Input detail", message, null); } }); return convertView; }
private LinearLayout getView(int position, Context context) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5); ll.setPadding(dp_5, dp_5, dp_5, dp_5); ImageView iv = new ImageView(context); iv.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(iconWidth, iconWidth); lpIv.gravity = Gravity.CENTER_HORIZONTAL; iv.setLayoutParams(lpIv); iv.setImageBitmap(getIcon(platforms[position])); ll.addView(iv); TextView tv = new TextView(context); tv.setTextColor(0xffffffff); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); tv.setSingleLine(); tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); lpTv.weight = 1; tv.setLayoutParams(lpTv); tv.setText(getName(platforms[position])); ll.addView(tv); return ll; }
@Override protected void onBindView(View view) { super.onBindView(view); TextView textView = (TextView) view.findViewById(android.R.id.title); if (textView != null) { textView.setSingleLine(false); } }
public TextView createHeaderView() { TextView view = new TextView(mContext); view.setLayoutParams(new ViewGroup.LayoutParams(mCustomDimens.WIDTH, mCustomDimens.HEIGHT)); view.setGravity(Gravity.CENTER); view.setSingleLine(); view.setTextSize(mCustomDimens.HEADER_TEXT_SIZE); return view; }
@Override public View newDropDownView(final int position, final ViewGroup parent) { final TextView res = (TextView) LayoutInflater.from(getContext()) .inflate(android.R.layout.simple_spinner_dropdown_item, parent, false); res.setSingleLine(false); return res; }
@Override protected void onBindView(View view) { super.onBindView(view); /* Some translations of Key Combination overflow a single line. Allow wrapping. */ TextView textView = (TextView) view.findViewById(android.R.id.title); if (textView != null) { textView.setSingleLine(false); } }
@Override protected void onBindView(View view) { super.onBindView(view); TextView title = (TextView) view.findViewById(android.R.id.title); if (title != null) { title.setSingleLine(false); title.setMaxLines(3); } }
@Override protected void onBindView(View view) { super.onBindView(view); TextView title = (TextView) view.findViewById(android.R.id.title); if (title != null) { title.setSingleLine(false); title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); } }
public PagerTitleStrip(Context context, AttributeSet attrs) { super(context, attrs); addView(mPrevText = new TextView(context)); addView(mCurrText = new TextView(context)); addView(mNextText = new TextView(context)); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); final int textAppearance = a.getResourceId(0, 0); if (textAppearance != 0) { mPrevText.setTextAppearance(context, textAppearance); mCurrText.setTextAppearance(context, textAppearance); mNextText.setTextAppearance(context, textAppearance); } if (a.hasValue(1)) { final int textColor = a.getColor(1, 0); mPrevText.setTextColor(textColor); mCurrText.setTextColor(textColor); mNextText.setTextColor(textColor); } final int textSize = a.getDimensionPixelSize(2, 0); if (textSize != 0) { mPrevText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); mCurrText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); mNextText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } a.recycle(); final int defaultColor = mPrevText.getTextColors().getDefaultColor(); final int transparentColor = (SIDE_ALPHA << 24) | (defaultColor & 0xFFFFFF); mPrevText.setTextColor(transparentColor); mNextText.setTextColor(transparentColor); mPrevText.setEllipsize(TruncateAt.END); mCurrText.setEllipsize(TruncateAt.END); mNextText.setEllipsize(TruncateAt.END); mPrevText.setSingleLine(); mCurrText.setSingleLine(); mNextText.setSingleLine(); final float density = context.getResources().getDisplayMetrics().density; mScaledTextSpacing = (int) (TEXT_SPACING * density); }
@Override public void setSingleLine(boolean singleLine) { super.setSingleLine(singleLine); if (singleLine) { mMaxLines = 1; } else { mMaxLines = NO_LINE_LIMIT; } reAdjust(); }
public AlbumView(Context context) { super(context); imageView = new BackupImageView(context); addView( imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setBackgroundColor(0x7f000000); addView( linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28, Gravity.LEFT | Gravity.BOTTOM)); nameTextView = new TextView(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); nameTextView.setTextColor(0xffffffff); nameTextView.setSingleLine(true); nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setMaxLines(1); nameTextView.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView( nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0)); countTextView = new TextView(context); countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); countTextView.setTextColor(0xffaaaaaa); countTextView.setSingleLine(true); countTextView.setEllipsize(TextUtils.TruncateAt.END); countTextView.setMaxLines(1); countTextView.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView( countTextView, LayoutHelper.createLinear( LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 4, 0, 4, 0)); selector = new View(context); selector.setBackgroundResource(R.drawable.list_selector); addView( selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); }
private TextView makeCrumbView(String name) { TextView tv = new TextView(mContext); tv.setTextAppearance(mContext, android.R.style.TextAppearance_Medium); tv.setPadding(mCrumbPadding, 0, mCrumbPadding, 0); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText(name); tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); tv.setSingleLine(); tv.setEllipsize(TextUtils.TruncateAt.END); return tv; }
/** * Instantiates a new ab tab item view. * * @param context the context * @param attrs the attrs */ public TabItemView(Context context, AttributeSet attrs) { super(context, attrs); this.setOrientation(LinearLayout.HORIZONTAL); this.mContext = context; mTextView = new TextView(context); mTextView.setGravity(Gravity.CENTER_HORIZONTAL); mTextView.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mTextView.setFocusable(true); // mTextView.setPadding(10, 0, 10, 0); mTextView.setSingleLine(); // mTextView.setBackgroundResource(R.drawable.actionbar_bg); this.addView(mTextView); }
@Override public void onBindView(View view) { super.onBindView(view); TextView textSummary = (TextView) view.findViewById(android.R.id.summary); if (textSummary != null) { textSummary.setSingleLine(); textSummary.setEllipsize(TextUtils.TruncateAt.MIDDLE); } Xlog.i(TAG, "summary is +" + this.getSummary()); }
/** Creates a view into which preview text can be placed. */ private TextView createPreviewTextView() { final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // final Resources res = getContext().getResources(); // final float textSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_text_size); final TextView textView = new TextView(getContext()); textView.setLayoutParams(params); textView.setTextColor(Color.WHITE); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mToastTextSize); textView.setSingleLine(true); textView.setEllipsize(TruncateAt.MIDDLE); textView.setGravity(Gravity.CENTER); textView.setAlpha(0f); return textView; }
public void clickTextView(final TextView textView, final int skillId) { textView.setMaxLines(1); textView.setSingleLine(true); textView.setEms(13); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setClickable(true); textView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { skillPageFlag = true; sellerSkillId = skillId; new regTask().execute("SellerMarket profile"); } }); }
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title); tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }