Java Code Examples for android.widget.TextView.setEllipsize()

The following are Jave code examples for showing how to use setEllipsize() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: airgram   File: PhotoPickerSearchCell.java   View Source Code Vote up 6 votes
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));
}
 
Example 2
Project: EasyAndroid   File: NewAuthEditText.java   View Source Code Vote up 6 votes
/**
 * 创建 TextView 并返回
 *
 * @return {@link TextView}
 */
private TextView createTextView()
{
    TextView tv = new TextView(context);
    tv.setGravity(Gravity.CENTER);
    tv.setTextColor(textColor);
    tv.setTextSize(textSize);
    tv.setMaxLines(1);
    tv.setEllipsize(TextUtils.TruncateAt.END);
    tv.setBackgroundDrawable(createFrameDrawableBg());
    return tv;
}
 
Example 3
Project: PlusGram   File: ShareDialogCell.java   View Source Code Vote up 6 votes
public ShareDialogCell(Context context) {
    super(context);
    setBackgroundResource(R.drawable.list_selector);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int nColor = themePrefs.getInt("chatAttachTextColor", 0xff757575);
    nameTextView = new TextView(context);
    //nameTextView.setTextColor(0xff212121);
    nameTextView.setTextColor(nColor != 0xff757575 ? nColor : 0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    nameTextView.setMaxLines(2);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(2);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 64, 6, 0));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setSize(24);
    checkBox.setCheckOffset(AndroidUtilities.dp(1));
    checkBox.setVisibility(VISIBLE);
    checkBox.setColor(0xff3ec1f9);
    addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 39, 0, 0));
}
 
Example 4
Project: Sortable_tableview_soussidev   File: SimpleTableDataAdapter.java   View Source Code Vote up 6 votes
@Override
public View getCellView(final int rowIndex, final int columnIndex, final ViewGroup parentView) {
    final TextView textView = new TextView(getContext());
    textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    textView.setTypeface(textView.getTypeface(), typeface);
    textView.setTextSize(textSize);
    textView.setTextColor(textColor);
    textView.setSingleLine();
    textView.setEllipsize(TextUtils.TruncateAt.END);

    try {
        final String textToShow = getItem(rowIndex)[columnIndex];
        textView.setText(textToShow);
    } catch (final IndexOutOfBoundsException e) {
        Log.w(LOG_TAG, "No Sting given for row " + rowIndex + ", column " + columnIndex + ". "
                + "Caught exception: " + e.toString());
        // Show no text
    }

    return textView;
}
 
Example 5
Project: gitio   File: HistoryItemCell.java   View Source Code Vote up 6 votes
public HistoryItemCell(Context context) {
    super(context);

    codeView = new TextView(context);
    codeView.setTextColor(Color.BLUE);
    codeView.setTextSize(24);
    codeView.setLines(1);
    codeView.setEllipsize(TextUtils.TruncateAt.END);
    addView(codeView);

    urlView = new TextView(context);
    urlView.setTextColor(Color.BLACK);
    urlView.setTextSize(16);
    urlView.setLines(1);
    urlView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    addView(urlView);

    dateView = new TextView(context);
    dateView.setTextColor(Color.LTGRAY);
    dateView.setTextSize(12);
    dateView.setGravity(Gravity.RIGHT);
    addView(dateView);
}
 
Example 6
Project: Sortable_tableview_soussidev   File: SimpleTableHeaderAdapter.java   View Source Code Vote up 6 votes
@Override
public View getHeaderView(final int columnIndex, final ViewGroup parentView) {
    final TextView textView = new TextView(getContext());

    if (columnIndex < headers.length) {
        textView.setText(headers[columnIndex]);
    }

    textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    textView.setTypeface(textView.getTypeface(), typeface);
    textView.setTextSize(textSize);
    textView.setTextColor(textColor);
    textView.setSingleLine();
    textView.setEllipsize(TextUtils.TruncateAt.END);

    return textView;
}
 
Example 7
Project: PlusGram   File: JoinSheetUserCell.java   View Source Code Vote up 6 votes
public JoinSheetUserCell(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xff212121);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    nameTextView.setMaxLines(1);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 64, 6, 0));
}
 
Example 8
Project: airgram   File: ChatAttachAlert.java   View Source Code Vote up 6 votes
public AttachBotButton(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(27));
    addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));

    nameTextView = new TextView(context);
    nameTextView.setTypeface(FontManager.instance().getTypeface());
    nameTextView.setTextColor(Theme.ATTACH_SHEET_TEXT_COLOR);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    nameTextView.setMaxLines(2);
    nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    nameTextView.setLines(2);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 65, 6, 0));
}
 
Example 9
Project: YCDialog   File: DialogAdapter.java   View Source Code Vote up 6 votes
LeftHolder(View view) {
    super(view);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    view.setLayoutParams(params);
    item = new TextView(view.getContext());
    item.setLayoutParams(params);
    item.setMaxLines(1);
    item.setEllipsize(TextUtils.TruncateAt.END);
    item.setGravity(Gravity.CENTER_VERTICAL);
    item.setTextColor(ContextCompat.getColor(view.getContext(), R.color.gray_black));
    item.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.app_normal_margin));
    item.setCompoundDrawablePadding(leftPadding);
    item.setPadding(padding, padding, padding, padding);

    TypedValue typedValue = new TypedValue();
    view.getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    item.setBackgroundResource(typedValue.resourceId);

    ((LinearLayout) view).addView(item);
}
 
Example 10
Project: SlidingSwitch   File: SlidingSwitch.java   View Source Code Vote up 5 votes
private TextView buildTextView(Context context, CharSequence text) {
    TextView textView = new TextView(context);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1);
    textView.setLayoutParams(params);
    textView.setTextColor(mTextColor);
    textView.setText(text);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize);
    textView.setMaxLines(3);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity(Gravity.CENTER);
    textView.setPadding(mPaddingHorizontal, mPaddingVertical, mPaddingHorizontal, mPaddingVertical);
    return textView;
}
 
Example 11
Project: GitHub   File: AbstractWheelTextAdapter.java   View Source Code Vote up 5 votes
/**
 * 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.setPadding(0, padding, 0, padding);
    view.setTextSize(textSize);
    view.setEllipsize(TextUtils.TruncateAt.END);
    view.setLines(1);
    //        view.setCompoundDrawablePadding(20);
    //        view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
}
 
Example 12
Project: Aurora   File: ExpandTextView.java   View Source Code Vote up 5 votes
public ExpandTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    mText = new TextView(context, attrs);
    mText.setTextColor(mTextColor);
    mText.setEllipsize(TextUtils.TruncateAt.END);
    mText.setMaxLines(mTextLine);
    addView(mText, params);
    mExpandText = new TextView(context);
    mExpandText.setTextColor(Color.TRANSPARENT);
    addView(mExpandText, params);
}
 
Example 13
Project: aos-Video   File: CastRowPresenter.java   View Source Code Vote up 5 votes
public CastViewHolder(ViewHolder parentViewHolder, View contentView) {
    super(parentViewHolder.view);

    mFullWidthViewHolder = parentViewHolder;
    mDirectorsTv = (TextView)contentView.findViewById(R.id.directors);
    mCastTv = (TextView)contentView.findViewById(R.id.cast);
    if (mMaxLines>0) {
        mCastTv.setMaxLines(mMaxLines);
        mCastTv.setEllipsize(TextUtils.TruncateAt.END);
    }
}
 
Example 14
Project: BBSSDK-for-Android   File: ForumForumView.java   View Source Code Vote up 5 votes
public View getView(int position, View convertView, ViewGroup parent) {
	LinearLayout llContent = new LinearLayout(getContext());
	llContent.setOrientation(LinearLayout.VERTICAL);
	final GlideImageView aivIcon = new GlideImageView(getContext());
	int aivIconWidth = ResHelper.dipToPx(getContext(), 40);
	LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(aivIconWidth, aivIconWidth);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llContent.addView(aivIcon, llp);

	TextView tvForumName = new TextView(getContext());
	tvForumName.setTextColor(0xff3a4045);
	tvForumName.setTextSize(TypedValue.COMPLEX_UNIT_PX, ResHelper.dipToPx(getContext(), 14));
	tvForumName.setEllipsize(TextUtils.TruncateAt.MIDDLE);
	tvForumName.setSingleLine();
	llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llp.topMargin = ResHelper.dipToPx(getContext(), 8);
	llContent.addView(tvForumName, llp);

	ForumForum forum = getItem(position);
	if (forum != null) {
		tvForumName.setText(forum.name);
		if (!TextUtils.isEmpty(forum.forumPic)) {
			aivIcon.setExecuteRound(ResHelper.dipToPx(getContext(), 5));
			aivIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
		}
		aivIcon.execute(forum.forumPic, forum.fid == 0 ? defaultTotalForumPic : defaultForumPic);
	} else {
		aivIcon.setImageResource(defaultForumPic);
	}
	return llContent;
}
 
Example 15
Project: PlusGram   File: MentionCell.java   View Source Code Vote up 5 votes
public MentionCell(Context context) {
    super(context);

    setOrientation(HORIZONTAL);

    setBackgroundResource(R.drawable.list_selector);

    avatarDrawable = new AvatarDrawable();
    avatarDrawable.setSmallStyle(true);

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(14));
    addView(imageView, LayoutHelper.createLinear(28, 28, 12, 4, 0, 0));

    nameTextView = new TextView(context);
    nameTextView.setTextColor(0xff000000);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    nameTextView.setSingleLine(true);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 0, 0));

    usernameTextView = new TextView(context);
    usernameTextView.setTextColor(0xff999999);
    usernameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    usernameTextView.setSingleLine(true);
    usernameTextView.setGravity(Gravity.LEFT);
    usernameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(usernameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 8, 0));
}
 
Example 16
Project: PlusGram   File: BotSwitchCell.java   View Source Code Vote up 5 votes
public BotSwitchCell(Context context) {
    super(context);
    setBackgroundResource(R.drawable.list_selector);

    textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTextColor(0xff4391cc);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setMaxLines(1);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 14, 0, 14, 0));
}
 
Example 17
Project: easyfilemanager   File: RecentsCreateFragment.java   View Source Code Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_doc_list, parent, false);
    }

    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final View line2 = convertView.findViewById(R.id.line2);

    final DocumentStack stack = getItem(position);
    iconMime.setImageDrawable(stack.root.loadIcon(context));

    final Drawable crumb = ContextCompat.getDrawable(context, R.drawable.ic_breadcrumb_arrow);
    crumb.setBounds(0, 0, crumb.getIntrinsicWidth(), crumb.getIntrinsicHeight());

    final SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(stack.root.title);
    for (int i = stack.size() - 2; i >= 0; i--) {
        appendDrawable(builder, crumb);
        builder.append(stack.get(i).displayName);
    }
    title.setText(builder);
    title.setEllipsize(TruncateAt.MIDDLE);

    if (line2 != null) line2.setVisibility(View.GONE);

    return convertView;
}
 
Example 18
Project: YouTube-Thumbnail-View   File: ThumbnailView.java   View Source Code Vote up 4 votes
private void init(Context context, AttributeSet attrs) {
   // Attributes
   final TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0);

   minThumbnailSize = attr.getInteger(R.styleable.ThumbnailView_youtube_minThumbnailWidth, DEFAULT_MIN_THUMBNAIL_SIZE);

   fadeDuration = DEFAULT_FADE_DURATION;

   titleVisible = attr.getBoolean(R.styleable.ThumbnailView_youtube_titleVisible, true);
   timeVisible = attr.getBoolean(R.styleable.ThumbnailView_youtube_timeVisible, true);

   final int titleColor = attr.getColor(R.styleable.ThumbnailView_youtube_titleColor, Color.WHITE);
   final int titleBackgroundColor = attr.getColor(R.styleable.ThumbnailView_youtube_titleBackgroundColor, 0x80000000);
   final int titlePaddingLeft = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_titlePaddingLeft, dpToPx(context, 10.0f));
   final int titlePaddingRight = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_titlePaddingRight, dpToPx(context, 10.0f));
   final int titlePaddingTop = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_titlePaddingTop, dpToPx(context, 5.0f));
   final int titlePaddingBottom = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_titlePaddingBottom, dpToPx(context, 5.0f));
   final float titleTextSize = attr.getDimension(R.styleable.ThumbnailView_youtube_titleTextSize, getResources().getDimension(R.dimen.title_text_size));
   final int titleMaxLines = attr.getInteger(R.styleable.ThumbnailView_youtube_titleMaxLines, DEFAULT_TITLE_MAX_LINES);

   final int timeColor = attr.getColor(R.styleable.ThumbnailView_youtube_timeColor, Color.WHITE);
   final int timeBackgroundColor = attr.getColor(R.styleable.ThumbnailView_youtube_timeBackgroundColor, 0x80000000);
   final int timePaddingLeft = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_timePaddingLeft, dpToPx(context, 5.0f));
   final int timePaddingRight = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_timePaddingRight, dpToPx(context, 5.0f));
   final int timePaddingTop = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_timePaddingTop, dpToPx(context, 0.0f));
   final int timePaddingBottom = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_timePaddingBottom, dpToPx(context, 0.0f));
   final int timeMarginBottom = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_timeMarginBottom, dpToPx(context, 10.0f));
   final int timeMarginRight = attr.getDimensionPixelSize(R.styleable.ThumbnailView_youtube_timeMarginRight, dpToPx(context, 10.0f));
   final float timeTextSize = attr.getDimension(R.styleable.ThumbnailView_youtube_timeTextSize, getResources().getDimension(R.dimen.time_text_size));

   attr.recycle();

   // Add thumbnailView image
   thumbnailView = new ImageView(context);
   thumbnailView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
   thumbnailView.setScaleType(ImageView.ScaleType.CENTER_CROP);

   addView(thumbnailView);

   // Add video titleView
   titleView = new TextView(context);
   titleView.setTextColor(titleColor);
   titleView.setBackgroundColor(titleBackgroundColor);
   titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
   titleView.setMaxLines(titleMaxLines);
   titleView.setEllipsize(TextUtils.TruncateAt.END);
   titleView.setPadding(titlePaddingLeft, titlePaddingTop, titlePaddingRight, titlePaddingBottom);
   titleView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
   titleView.setVisibility(GONE);

   addView(titleView);

   // Add video length
   timeView = new TextView(context);
   timeView.setTextColor(timeColor);
   timeView.setBackgroundColor(timeBackgroundColor);
   timeView.setTextSize(TypedValue.COMPLEX_UNIT_PX, timeTextSize);
   timeView.setMaxLines(1);
   timeView.setPadding(timePaddingLeft, timePaddingTop, timePaddingRight, timePaddingBottom);

   final LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   lp.setMargins(0, 0, timeMarginRight, timeMarginBottom);
   lp.addRule(ALIGN_PARENT_BOTTOM);
   lp.addRule(ALIGN_PARENT_RIGHT);
   timeView.setLayoutParams(lp);
   timeView.setVisibility(GONE);

   addView(timeView);

   // Clickable
   setClickable(true);
   setFocusable(true);
}
 
Example 19
Project: TIIEHenry-Android-SDK   File: TabLayout.java   View Source Code Vote up 4 votes
final void update() {
  final Tab tab = mTab;
  final View custom = tab.getCustomView();
  if (custom != null) {
	final ViewParent customParent = custom.getParent();
	if (customParent != this) {
	  if (customParent != null) {
		((ViewGroup) customParent).removeView(custom);
	  }
	  addView(custom);
	}
	mCustomView = custom;
	if (mTextView != null) {
	  mTextView.setVisibility(GONE);
	}
	if (mIconView != null) {
	  mIconView.setVisibility(GONE);
	  mIconView.setImageDrawable(null);
	}
  } else {
	if (mCustomView != null) {
	  removeView(mCustomView);
	  mCustomView = null;
	}

	final Drawable icon = tab.getIcon();
	final CharSequence text = tab.getText();

	if (icon != null) {
	  if (mIconView == null) {
		ImageView iconView = new ImageView(getContext());
		LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
										   LayoutParams.WRAP_CONTENT);
		lp.gravity = Gravity.CENTER_VERTICAL;
		iconView.setLayoutParams(lp);
		addView(iconView, 0);
		mIconView = iconView;
	  }
	  mIconView.setImageDrawable(icon);
	  mIconView.setVisibility(VISIBLE);
	} else if (mIconView != null) {
	  mIconView.setVisibility(GONE);
	  mIconView.setImageDrawable(null);
	}

	final boolean hasText = !TextUtils.isEmpty(text);
	if (hasText) {
	  if (mTextView == null) {
		TextView textView = new TextView(getContext());
		textView.setTextAppearance(getContext(), mTabTextAppearance);
		textView.setMaxLines(MAX_TAB_TEXT_LINES);
		textView.setEllipsize(TextUtils.TruncateAt.END);
		textView.setGravity(Gravity.CENTER);
		if (mTabSelectedTextColorSet) {
		  textView.setTextColor(createColorStateList(
								  textView.getCurrentTextColor(), mTabSelectedTextColor));
		}

		addView(textView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		mTextView = textView;
	  }
	  mTextView.setText(text);
	  mTextView.setVisibility(VISIBLE);
	} else if (mTextView != null) {
	  mTextView.setVisibility(GONE);
	  mTextView.setText(null);
	}

	if (mIconView != null) {
	  mIconView.setContentDescription(tab.getContentDescription());
	}

	if (!hasText && !TextUtils.isEmpty(tab.getContentDescription())) {
	  setOnLongClickListener(this);
	} else {
	  setOnLongClickListener(null);
	  setLongClickable(false);
	}
  }
}
 
Example 20
Project: mobile-store   File: AppDetailsRecyclerViewAdapter.java   View Source Code Vote up 4 votes
HeaderViewHolder(View view) {
    super(view);
    iconView = (ImageView) view.findViewById(R.id.icon);
    titleView = (TextView) view.findViewById(R.id.title);
    authorView = (TextView) view.findViewById(R.id.author);
    lastUpdateView = (TextView) view.findViewById(R.id.text_last_update);
    whatsNewView = (TextView) view.findViewById(R.id.whats_new);
    descriptionView = (TextView) view.findViewById(R.id.description);
    descriptionMoreView = (TextView) view.findViewById(R.id.description_more);
    antiFeaturesLabelView = (TextView) view.findViewById(R.id.label_anti_features);
    antiFeaturesView = (TextView) view.findViewById(R.id.text_anti_features);
    antiFeaturesWarningView = view.findViewById(R.id.anti_features_warning);
    buttonLayout = view.findViewById(R.id.button_layout);
    buttonPrimaryView = (Button) view.findViewById(R.id.primaryButtonView);
    buttonSecondaryView = (Button) view.findViewById(R.id.secondaryButtonView);
    progressLayout = view.findViewById(R.id.progress_layout);
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    progressLabel = (TextView) view.findViewById(R.id.progress_label);
    progressPercent = (TextView) view.findViewById(R.id.progress_percent);
    progressCancel = view.findViewById(R.id.progress_cancel);
    displayImageOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.NONE)
            .showImageOnLoading(R.drawable.ic_repo_app_default)
            .showImageForEmptyUri(R.drawable.ic_repo_app_default)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
    descriptionView.setMaxLines(MAX_LINES);
    descriptionView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    descriptionMoreView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Make this "header section" the focused child, so that RecyclerView will use
            // it as the anchor in the layout process. Otherwise the RV might select another
            // view as the anchor, resulting in that the top of this view is instead scrolled
            // off the screen. Refer to LinearLayoutManager.updateAnchorFromChildren(...).
            recyclerView.requestChildFocus(itemView, itemView);
            if (TextViewCompat.getMaxLines(descriptionView) != MAX_LINES) {
                descriptionView.setMaxLines(MAX_LINES);
                descriptionMoreView.setText(R.string.more);
                descriptionIsExpanded = false;
            } else {
                descriptionView.setMaxLines(Integer.MAX_VALUE);
                descriptionMoreView.setText(R.string.less);
                descriptionIsExpanded = true;
            }
            updateAntiFeaturesWarning();
        }
    });
}