本文整理匯總了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();
}