本文整理汇总了Java中android.widget.TextView.requestLayout方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.requestLayout方法的具体用法?Java TextView.requestLayout怎么用?Java TextView.requestLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.requestLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshPanel
import android.widget.TextView; //导入方法依赖的package包/类
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("");
}
}
}
}
}
示例2: setFontTypeface
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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();
}
示例3: setAlbum
import android.widget.TextView; //导入方法依赖的package包/类
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();
}
}
}
}
示例4: setFontSize
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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();
}
示例5: setTextHTML
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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();
}
示例6: setText
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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();
}
示例7: setPadding
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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();
}