本文整理了Java中android.widget.TextView.addOnLayoutChangeListener()
方法的一些代码示例,展示了TextView.addOnLayoutChangeListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.addOnLayoutChangeListener()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:addOnLayoutChangeListener
暂无
代码示例来源:origin: grantland/android-autofittextview
/**
* Set the enabled state of automatically resizing text.
*/
public AutofitHelper setEnabled(boolean enabled) {
if (mEnabled != enabled) {
mEnabled = enabled;
if (enabled) {
mTextView.addTextChangedListener(mTextWatcher);
mTextView.addOnLayoutChangeListener(mOnLayoutChangeListener);
autofit();
} else {
mTextView.removeTextChangedListener(mTextWatcher);
mTextView.removeOnLayoutChangeListener(mOnLayoutChangeListener);
mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
}
}
return this;
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
TextView textView = ((TextView) findViewById(R.id.home_trafic_text));
textView.setText(getString(R.string.loading));
textView.setEnabled(true); // Thanks to Romain Guy
textView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
LayoutParams params = v.getLayoutParams();
params.width = right - left;
params.height = bottom - top;
params.weight = 0;
v.removeOnLayoutChangeListener(this);
v.setLayoutParams(params);
}
});
}
代码示例来源:origin: AlexMofer/ProjectX
PrinterStateDialog(@NonNull Context context, @NonNull OnDialogListener listener) {
super(context, AlertDialogUtils.getAlertDialogTheme(context));
mListener = listener;
setContentView(R.layout.dlg_printer_state);
mVContent = findViewById(R.id.dps_sv_content);
mVState = findViewById(R.id.dps_tv_state);
mVNegative = findViewById(R.id.dps_btn_negative);
mVPositive = findViewById(R.id.dps_btn_positive);
mVState.addOnLayoutChangeListener(this);
mVNegative.setOnClickListener(this);
mVPositive.setOnClickListener(this);
}
代码示例来源:origin: victorminerva/AutoResizeEditText
/**
* Set the enabled state of automatically resizing text.
*/
public AutofitHelper setEnabled(boolean enabled) {
if (mEnabled != enabled) {
mEnabled = enabled;
if (enabled) {
mTextView.addTextChangedListener(mTextWatcher);
mTextView.addOnLayoutChangeListener(mOnLayoutChangeListener);
autofit();
} else {
mTextView.removeTextChangedListener(mTextWatcher);
mTextView.removeOnLayoutChangeListener(mOnLayoutChangeListener);
mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
}
}
return this;
}
代码示例来源:origin: derry/delion
/**
* 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);
}
代码示例来源:origin: derry/delion
mUrlBar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
内容来源于网络,如有侵权,请联系作者删除!