Java Code Examples for android.widget.TextView#requestLayout()
The following examples show how to use
android.widget.TextView#requestLayout() .
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: TextSharedElementCallback.java From android-topeka with Apache License 2.0 | 6 votes |
@Override public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { TextView initialView = getTextView(sharedElements); if (initialView == null) { Log.w(TAG, "onSharedElementEnd: No shared TextView, skipping"); return; } // Setup the TextView's end values. initialView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTargetViewTextSize); ViewUtils.setPaddingStart(initialView, mTargetViewPaddingStart); // Re-measure the TextView (since the text size has changed). int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); initialView.measure(widthSpec, heightSpec); initialView.requestLayout(); }
Example 2
Source File: ObservationListAdapter.java From mage-android with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(ObservationProperty property) { if (isCancelled()) { property = null; } TextView textView = reference.get(); if (textView != null) { if (property == null || property.isEmpty()) { textView.setVisibility(View.GONE); } else { textView.setText(property.getValue().toString()); textView.setVisibility(View.VISIBLE); } textView.requestLayout(); } }
Example 3
Source File: TextSharedElementCallback.java From CoolSignIn with Apache License 2.0 | 6 votes |
@Override public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { TextView initialView = getTextView(sharedElements); if (initialView == null) { Log.w(TAG, "onSharedElementEnd: No shared TextView, skipping"); return; } // Setup the TextView's end values. initialView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTargetViewTextSize); ViewUtils.setPaddingStart(initialView, mTargetViewPaddingStart); // Re-measure the TextView (since the text size has changed). int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); initialView.measure(widthSpec, heightSpec); initialView.requestLayout(); }
Example 4
Source File: TextViewUtil.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Sets the font typeface for a {@link TextView}. * * @param textview text view instance * @param typeface one of @link Component#TYPEFACE_DEFAULT}, * {@link Component#TYPEFACE_SERIF}, * {@link Component#TYPEFACE_SANSSERIF} or * {@link Component#TYPEFACE_MONOSPACE} * @param bold true for bold, false for not bold * @param italic true for italic, false for not italic */ public static void setFontTypeface(TextView textview, int typeface, boolean bold, boolean italic) { Typeface tf; switch (typeface) { default: throw new IllegalArgumentException(); case Component.TYPEFACE_DEFAULT: tf = Typeface.DEFAULT; break; case Component.TYPEFACE_SERIF: tf = Typeface.SERIF; break; case Component.TYPEFACE_SANSSERIF: tf = Typeface.SANS_SERIF; break; case Component.TYPEFACE_MONOSPACE: tf = Typeface.MONOSPACE; break; } int style = 0; if (bold) { style |= Typeface.BOLD; } if (italic) { style |= Typeface.ITALIC; } textview.setTypeface(Typeface.create(tf, style)); textview.requestLayout(); }
Example 5
Source File: LoadImageAsync.java From aurora-imui with MIT License | 5 votes |
@Override protected void onPostExecute(Drawable drawable) { TextView textView = mTextView.get(); if (drawable != null && textView != null) { mDrawable.get().drawable = drawable; textView.requestLayout(); } }
Example 6
Source File: PlatformPageAdapter.java From YiZhi with Apache License 2.0 | 4 votes |
private void refreshPanel(LinearLayout[] llCells, Object[] logos) { int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back"); int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor"); for (int i = 0; i < logos.length; i++) { ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0)); TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1)); if (logos[i] == null) { ivLogo.setVisibility(View.INVISIBLE); tvName.setVisibility(View.INVISIBLE); llCells[i].setBackgroundResource(disableBack); llCells[i].setOnClickListener(null); } else { ivLogo.setVisibility(View.VISIBLE); tvName.setVisibility(View.VISIBLE); ivLogo.requestLayout(); tvName.requestLayout(); llCells[i].setBackgroundResource(cellBack); llCells[i].setOnClickListener(this); llCells[i].setTag(logos[i]); if (logos[i] instanceof CustomerLogo) { CustomerLogo logo = ResHelper.forceCast(logos[i]); if (logo.logo != null) { ivLogo.setImageBitmap(logo.logo); } else { ivLogo.setImageBitmap(null); } if (logo.label != null) { tvName.setText(logo.label); } else { tvName.setText(""); } } else { Platform plat = ResHelper.forceCast(logos[i]); String name = plat.getName().toLowerCase(); int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name); if (resId > 0) { ivLogo.setImageResource(resId); } else { ivLogo.setImageBitmap(null); } resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name); if (resId > 0) { tvName.setText(resId); } else { tvName.setText(""); } } } } }
Example 7
Source File: PlatformPageAdapter.java From enjoyshop with Apache License 2.0 | 4 votes |
private void refreshPanel(LinearLayout[] llCells, Object[] logos) { int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back"); int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor"); for (int i = 0; i < logos.length; i++) { ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0)); TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1)); if (logos[i] == null) { ivLogo.setVisibility(View.INVISIBLE); tvName.setVisibility(View.INVISIBLE); llCells[i].setBackgroundResource(disableBack); llCells[i].setOnClickListener(null); } else { ivLogo.setVisibility(View.VISIBLE); tvName.setVisibility(View.VISIBLE); ivLogo.requestLayout(); tvName.requestLayout(); llCells[i].setBackgroundResource(cellBack); llCells[i].setOnClickListener(this); llCells[i].setTag(logos[i]); if (logos[i] instanceof CustomerLogo) { CustomerLogo logo = ResHelper.forceCast(logos[i]); if (logo.logo != null) { ivLogo.setImageBitmap(logo.logo); } else { ivLogo.setImageBitmap(null); } if (logo.label != null) { tvName.setText(logo.label); } else { tvName.setText(""); } } else { Platform plat = ResHelper.forceCast(logos[i]); String name = plat.getName().toLowerCase(); int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name); if (resId > 0) { ivLogo.setImageResource(resId); } else { ivLogo.setImageBitmap(null); } resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name); if (resId > 0) { tvName.setText(resId); } else { tvName.setText(""); } } } } }
Example 8
Source File: AlbumHolder.java From Camera-Roll-Android-App with Apache License 2.0 | 4 votes |
public void setAlbum(Album album) { if (album == null) { //Error album album = MediaProvider.getErrorAlbum(); } this.album = album; TextView nameTv = itemView.findViewById(R.id.name); nameTv.setText(album.getName()); //to fix ellipsize nameTv.requestLayout(); //pinned indicator /*Drawable pinIndicator = null; if (album.pinned) { pinIndicator = AppCompatResources .getDrawable(getContext(), R.drawable.pin_indicator); if (pinIndicator != null) { int color = nameTv.getTextColors().getDefaultColor(); DrawableCompat.wrap(pinIndicator); DrawableCompat.setTint(pinIndicator, color); DrawableCompat.unwrap(pinIndicator); } } nameTv.setCompoundDrawablesRelativeWithIntrinsicBounds( null, null, pinIndicator, null);*/ //set album itemCount int itemCount = album.getAlbumItems().size(); boolean oneItem = itemCount == 1; String count = getContext().getString(oneItem ? R.string.item_count : R.string.items_count, itemCount); ((TextView) itemView.findViewById(R.id.count)).setText(Html.fromHtml(count)); ImageView hiddenFolderIndicator = itemView.findViewById(R.id.hidden_folder_indicator); if (hiddenFolderIndicator != null) { hiddenFolderIndicator .setVisibility(album.isHidden() ? View.VISIBLE : View.GONE); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !(album instanceof VirtualAlbum)) { ImageView removableStorageIndicator = itemView.findViewById(R.id.removable_storage_indicator); if (removableStorageIndicator != null) { try { boolean removable = Environment .isExternalStorageRemovable(new File(album.getPath())); removableStorageIndicator .setVisibility(removable ? View.VISIBLE : View.GONE); } catch (IllegalArgumentException e) { e.printStackTrace(); } } } }
Example 9
Source File: PlatformPageAdapter.java From LQRWeChat with MIT License | 4 votes |
private void refreshPanel(LinearLayout[] llCells, Object[] logos) { int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back"); int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor"); for (int i = 0; i < logos.length; i++) { ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0)); TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1)); if (logos[i] == null) { ivLogo.setVisibility(View.INVISIBLE); tvName.setVisibility(View.INVISIBLE); llCells[i].setBackgroundResource(disableBack); llCells[i].setOnClickListener(null); } else { ivLogo.setVisibility(View.VISIBLE); tvName.setVisibility(View.VISIBLE); ivLogo.requestLayout(); tvName.requestLayout(); llCells[i].setBackgroundResource(cellBack); llCells[i].setOnClickListener(this); llCells[i].setTag(logos[i]); if (logos[i] instanceof CustomerLogo) { CustomerLogo logo = ResHelper.forceCast(logos[i]); if (logo.logo != null) { ivLogo.setImageBitmap(logo.logo); } else { ivLogo.setImageBitmap(null); } if (logo.label != null) { tvName.setText(logo.label); } else { tvName.setText(""); } } else { Platform plat = ResHelper.forceCast(logos[i]); String name = plat.getName().toLowerCase(); int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name); if (resId > 0) { ivLogo.setImageResource(resId); } else { ivLogo.setImageBitmap(null); } resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name); if (resId > 0) { tvName.setText(resId); } else { tvName.setText(""); } } } } }
Example 10
Source File: MainActivity.java From ScalableLayout with Apache License 2.0 | 4 votes |
public void onClick_SetMoreText(View view) { TextView tv = (TextView) findViewById(R.id.tv_moretext); tv.setText(tv.getText() + "커"); tv.requestLayout(); }
Example 11
Source File: MainActivity.java From ScalableLayout with Apache License 2.0 | 4 votes |
public void onClick_SetLessText(View view) { TextView tv = (TextView) findViewById(R.id.tv_moretext); tv.setText(tv.getText().subSequence(1, tv.getText().length())); tv.requestLayout(); }
Example 12
Source File: EditorActivity.java From APDE with GNU General Public License v2.0 | 4 votes |
/** * Fix inconsistencies in the vertical distribution of the content area views */ public void refreshMessageAreaLocation() { //Obtain some references final View content = findViewById(R.id.content); final View console = findViewById(R.id.console_wrapper); final View code = getSelectedCodeAreaScroller(); final TextView messageArea = (TextView) findViewById(R.id.message); final FrameLayout autoCompileProgress = findViewById(R.id.auto_compile_progress_wrapper); if (firstResize) { //Use some better layout parameters - this switches from fractions/layout weights to absolute values code.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, code.getHeight())); console.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, console.getHeight())); firstResize = false; } messageArea.requestLayout(); messageArea.post(() -> { //We need to use this in case the message area is partially off the screen //This is the DESIRED height, not the ACTUAL height message = getTextViewHeight(getApplicationContext(), messageArea.getText().toString(), messageArea.getTextSize(), findViewById(R.id.message_char_insert_wrapper).getWidth(), messageArea.getPaddingTop()); int consoleSize = content.getHeight() - code.getHeight() - message - (extraHeaderView != null ? extraHeaderView.getHeight() : 0) - tabBarContainer.getHeight() - autoCompileProgress.getHeight(); //We can't shrink the console if it's hidden (like when the keyboard is visible)... //...so shrink the code area instead if (consoleSize < 0 || consoleWasHidden || keyboardVisible) { console.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0)); code.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, content.getHeight() - message - (extraHeaderView != null ? extraHeaderView.getHeight() : 0) - tabBarContainer.getHeight() - autoCompileProgress.getHeight())); consoleWasHidden = true; } else { console.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, consoleSize)); consoleWasHidden = false; } }); }
Example 13
Source File: TextViewUtil.java From appinventor-extensions with Apache License 2.0 | 2 votes |
/** * Sets the font size for a {@link TextView}. * * @param textview text view instance * @param size font size in pixel */ public static void setFontSize(TextView textview, float size) { textview.setTextSize(size); textview.requestLayout(); }
Example 14
Source File: TextViewUtil.java From appinventor-extensions with Apache License 2.0 | 2 votes |
/** * Sets the text for a {@link TextView}. * * @param textview text view instance * @param text new text to be shown */ public static void setTextHTML(TextView textview, String text) { textview.setText(Html.fromHtml(text)); textview.requestLayout(); }
Example 15
Source File: TextViewUtil.java From appinventor-extensions with Apache License 2.0 | 2 votes |
/** * Sets the text for a {@link TextView}. * * @param textview text view instance * @param text new text to be shown */ public static void setText(TextView textview, String text) { textview.setText(text); textview.requestLayout(); }
Example 16
Source File: TextViewUtil.java From appinventor-extensions with Apache License 2.0 | 2 votes |
/** * Sets the padding for a {@link TextView}. * * @param textview text view instance * @param padding left and right padding to be set */ public static void setPadding(TextView textview, int padding) { textview.setPadding(padding, padding, 0, 0); textview.requestLayout(); }