Java Code Examples for android.widget.TextView#addOnLayoutChangeListener()
The following examples show how to use
android.widget.TextView#addOnLayoutChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebappUrlBar.java From delion with Apache License 2.0 | 5 votes |
/** * Creates a WebappUrlBar. * @param context Context to grab resources from. */ public WebappUrlBar(Context context, AttributeSet attrSet) { super(context, attrSet); mIconResourceWidths = new SparseIntArray(); mUrlBar = new TextView(context); mUrlBar.setSingleLine(true); mUrlBar.setGravity(Gravity.CENTER_VERTICAL); mUrlBar.setMovementMethod(ScrollingMovementMethod.getInstance()); mUrlBar.setHorizontalFadingEdgeEnabled(true); mSeparator = new View(context); addView(mUrlBar, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); addView(mSeparator, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 1, Gravity.BOTTOM)); // Set the colors. mSeparator.setBackgroundColor(ApiCompatibilityUtils.getColor(context.getResources(), R.color.webapp_url_bar_separator)); setBackgroundColor(ApiCompatibilityUtils.getColor(context.getResources(), R.color.webapp_url_bar_bg)); // Listen for changes in the URL bar's size. mUrlBar.addOnLayoutChangeListener(this); }
Example 2
Source File: WebappUrlBar.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates a WebappUrlBar. * @param context Context to grab resources from. */ public WebappUrlBar(Context context, AttributeSet attrSet) { super(context, attrSet); mIconResourceWidths = new SparseIntArray(); mUrlBar = new TextView(context); mUrlBar.setSingleLine(true); mUrlBar.setGravity(Gravity.CENTER_VERTICAL); mUrlBar.setMovementMethod(ScrollingMovementMethod.getInstance()); mUrlBar.setHorizontalFadingEdgeEnabled(true); mSeparator = new View(context); addView(mUrlBar, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); addView(mSeparator, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 1, Gravity.BOTTOM)); // Set the colors. mSeparator.setBackgroundColor(ApiCompatibilityUtils.getColor(context.getResources(), R.color.webapp_url_bar_separator)); setBackgroundColor(ApiCompatibilityUtils.getColor(context.getResources(), R.color.webapp_url_bar_bg)); // Listen for changes in the URL bar's size. mUrlBar.addOnLayoutChangeListener(this); }
Example 3
Source File: CaptionedImageView.java From auid2 with Apache License 2.0 | 5 votes |
private void init(Context context) { inflate(context, R.layout.captioned_image_view, this); mTextView = (TextView) findViewById(R.id.text); mImageView = (SquareImageView) findViewById(R.id.image); mScrimColor = getResources().getColor(R.color.grid_item_scrim); mTextView.addOnLayoutChangeListener(this); }
Example 4
Source File: CaptionedImageView.java From auid2 with Apache License 2.0 | 5 votes |
private void init(Context context) { inflate(context, R.layout.captioned_image_view, this); mTextView = (TextView) findViewById(R.id.text); mImageView = (SquareImageView) findViewById(R.id.image); mScrimColor = getResources().getColor(R.color.grid_item_scrim); mTextView.addOnLayoutChangeListener(this); }
Example 5
Source File: CaptionedImageView.java From auid2 with Apache License 2.0 | 5 votes |
private void init(Context context) { inflate(context, R.layout.captioned_image_view, this); mTextView = (TextView) findViewById(R.id.text); mImageView = (SquareImageView) findViewById(R.id.image); mScrimColor = getResources().getColor(R.color.grid_item_scrim); mTextView.addOnLayoutChangeListener(this); }
Example 6
Source File: WebappUrlBar.java From 365browser with Apache License 2.0 | 5 votes |
/** * Creates a WebappUrlBar. * @param context Context to grab resources from. */ public WebappUrlBar(Context context, AttributeSet attrSet) { super(context, attrSet); mIconResourceWidths = new SparseIntArray(); mUrlBar = new TextView(context); mUrlBar.setSingleLine(true); mUrlBar.setGravity(Gravity.CENTER_VERTICAL); mUrlBar.setMovementMethod(ScrollingMovementMethod.getInstance()); mUrlBar.setHorizontalFadingEdgeEnabled(true); mSeparator = new View(context); addView(mUrlBar, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); addView(mSeparator, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 1, Gravity.BOTTOM)); // Set the colors. mSeparator.setBackgroundColor(ApiCompatibilityUtils.getColor(context.getResources(), R.color.webapp_url_bar_separator)); setBackgroundColor(ApiCompatibilityUtils.getColor(context.getResources(), R.color.webapp_url_bar_bg)); // Listen for changes in the URL bar's size. mUrlBar.addOnLayoutChangeListener(this); }
Example 7
Source File: AbstractDetailsDescriptionPresenter.java From adt-leanback-support with Apache License 2.0 | 5 votes |
public ViewHolder(View view) { super(view); mTitle = (TextView) view.findViewById(R.id.lb_details_description_title); mSubtitle = (TextView) view.findViewById(R.id.lb_details_description_subtitle); mBody = (TextView) view.findViewById(R.id.lb_details_description_body); FontMetricsInt titleFontMetricsInt = getFontMetricsInt(mTitle); final int titleAscent = view.getResources().getDimensionPixelSize( R.dimen.lb_details_description_title_baseline); // Ascent is negative mTitleMargin = titleAscent + titleFontMetricsInt.ascent; mUnderTitleBaselineMargin = view.getResources().getDimensionPixelSize( R.dimen.lb_details_description_under_title_baseline_margin); mUnderSubtitleBaselineMargin = view.getResources().getDimensionPixelSize( R.dimen.lb_details_description_under_subtitle_baseline_margin); mTitleLineSpacing = view.getResources().getDimensionPixelSize( R.dimen.lb_details_description_title_line_spacing); mBodyLineSpacing = view.getResources().getDimensionPixelSize( R.dimen.lb_details_description_body_line_spacing); mBodyMaxLines = view.getResources().getInteger( R.integer.lb_details_description_body_max_lines); mBodyMinLines = view.getResources().getInteger( R.integer.lb_details_description_body_min_lines); mTitleFontMetricsInt = getFontMetricsInt(mTitle); mSubtitleFontMetricsInt = getFontMetricsInt(mSubtitle); mBodyFontMetricsInt = getFontMetricsInt(mBody); mTitle.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mBody.setMaxLines(mTitle.getLineCount() > 1 ? mBodyMinLines : mBodyMaxLines); } }); }
Example 8
Source File: MyAbstractDetailsPresenter.java From jellyfin-androidtv with GNU General Public License v2.0 | 4 votes |
public ViewHolder(View view) { super(view); mTitle = (TextView) view.findViewById(androidx.leanback.R.id.lb_details_description_title); mSubtitle = (TextView) view.findViewById(androidx.leanback.R.id.lb_details_description_subtitle); mActivity = (Activity) view.getContext(); mInfoRow = new LinearLayout(mActivity); LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(Utils.convertDpToPixel(mActivity, 500), Utils.convertDpToPixel(mActivity,20)); layout.setMargins(0,15,0,0); mInfoRow.setLayoutParams(layout); //Replace subtitle with our info row ViewGroup parent = (ViewGroup) view; int index = parent.indexOfChild(mSubtitle); parent.removeView(mSubtitle); parent.addView(mInfoRow, index); mBody = (TextView) view.findViewById(androidx.leanback.R.id.lb_details_description_body); Paint.FontMetricsInt titleFontMetricsInt = getFontMetricsInt(mTitle); final int titleAscent = view.getResources().getDimensionPixelSize( androidx.leanback.R.dimen.lb_details_description_title_baseline); // Ascent is negative mTitleMargin = titleAscent + titleFontMetricsInt.ascent; mUnderTitleBaselineMargin = view.getResources().getDimensionPixelSize( androidx.leanback.R.dimen.lb_details_description_under_title_baseline_margin); mUnderSubtitleBaselineMargin = view.getResources().getDimensionPixelSize( androidx.leanback.R.dimen.lb_details_description_under_subtitle_baseline_margin); mTitleLineSpacing = view.getResources().getDimensionPixelSize( androidx.leanback.R.dimen.lb_details_description_title_line_spacing); mBodyLineSpacing = view.getResources().getDimensionPixelSize( androidx.leanback.R.dimen.lb_details_description_body_line_spacing); mBodyMaxLines = 6; mBodyMinLines = 4; mTitleFontMetricsInt = getFontMetricsInt(mTitle); mSubtitleFontMetricsInt = getFontMetricsInt(mSubtitle); mBodyFontMetricsInt = getFontMetricsInt(mBody); mTitle.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mBody.setMaxLines(mTitle.getLineCount() > 1 ? mBodyMinLines : mBodyMaxLines); } }); }
Example 9
Source File: ChartHeaderView.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public ChartHeaderView(Context context) { super(context); TextPaint textPaint = new TextPaint(); textPaint.setTextSize(14); textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textMargin = (int) textPaint.measureText("00 MMM 0000 - 00 MMM 000"); title = new TextView(context); title.setTextSize(15); title.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); addView(title, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 16, 0, textMargin, 0)); back = new TextView(context); back.setTextSize(15); back.setTypeface(Typeface.DEFAULT_BOLD); back.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); addView(back, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 8, 0, 8, 0)); dates = new TextView(context); dates.setTextSize(13); dates.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); dates.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); addView(dates, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.CENTER_VERTICAL, 16, 0, 16, 0)); datesTmp = new TextView(context); datesTmp.setTextSize(13); datesTmp.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); datesTmp.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); addView(datesTmp, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.CENTER_VERTICAL, 16, 0, 16, 0)); datesTmp.setVisibility(View.GONE); back.setVisibility(View.GONE); back.setText(LocaleController.getString("ZoomOut", R.string.ZoomOut)); zoomIcon = ContextCompat.getDrawable(getContext(), R.drawable.stats_zoom); back.setCompoundDrawablesWithIntrinsicBounds(zoomIcon, null, null, null); back.setCompoundDrawablePadding(AndroidUtilities.dp(4)); back.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(4), AndroidUtilities.dp(8), AndroidUtilities.dp(4)); back.setBackground(Theme.getRoundRectSelectorDrawable(Theme.getColor(Theme.key_featuredStickers_removeButtonText))); datesTmp.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { datesTmp.setPivotX(datesTmp.getMeasuredWidth() * 0.7f); dates.setPivotX(dates.getMeasuredWidth() * 0.7f); }); recolor(); }
Example 10
Source File: ChartHeaderView.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ChartHeaderView(Context context) { super(context); TextPaint textPaint = new TextPaint(); textPaint.setTextSize(14); textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textMargin = (int) textPaint.measureText("00 MMM 0000 - 00 MMM 000"); title = new TextView(context); title.setTextSize(15); title.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); addView(title, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 16, 0, textMargin, 0)); back = new TextView(context); back.setTextSize(15); back.setTypeface(Typeface.DEFAULT_BOLD); back.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); addView(back, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 8, 0, 8, 0)); dates = new TextView(context); dates.setTextSize(13); dates.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); dates.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); addView(dates, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.CENTER_VERTICAL, 16, 0, 16, 0)); datesTmp = new TextView(context); datesTmp.setTextSize(13); datesTmp.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); datesTmp.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); addView(datesTmp, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.CENTER_VERTICAL, 16, 0, 16, 0)); datesTmp.setVisibility(View.GONE); back.setVisibility(View.GONE); back.setText(LocaleController.getString("ZoomOut", R.string.ZoomOut)); zoomIcon = ContextCompat.getDrawable(getContext(), R.drawable.stats_zoom); back.setCompoundDrawablesWithIntrinsicBounds(zoomIcon, null, null, null); back.setCompoundDrawablePadding(AndroidUtilities.dp(4)); back.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(4), AndroidUtilities.dp(8), AndroidUtilities.dp(4)); back.setBackground(Theme.getRoundRectSelectorDrawable(Theme.getColor(Theme.key_featuredStickers_removeButtonText))); datesTmp.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { datesTmp.setPivotX(datesTmp.getMeasuredWidth() * 0.7f); dates.setPivotX(dates.getMeasuredWidth() * 0.7f); }); recolor(); }