本文整理汇总了Java中android.support.v4.view.ViewCompat.setAccessibilityLiveRegion方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.setAccessibilityLiveRegion方法的具体用法?Java ViewCompat.setAccessibilityLiveRegion怎么用?Java ViewCompat.setAccessibilityLiveRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.setAccessibilityLiveRegion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setErrorEnabled
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void setErrorEnabled(boolean enabled) {
if (this.mErrorEnabled != enabled) {
if (this.mErrorView != null) {
ViewCompat.animate(this.mErrorView).cancel();
}
if (enabled) {
this.mErrorView = new TextView(getContext());
try {
this.mErrorView.setTextAppearance(getContext(), this.mErrorTextAppearance);
} catch (Exception e) {
this.mErrorView.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Caption);
this.mErrorView.setTextColor(ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
}
this.mErrorView.setVisibility(4);
ViewCompat.setAccessibilityLiveRegion(this.mErrorView, 1);
addIndicator(this.mErrorView, 0);
} else {
this.mErrorShown = false;
updateEditTextBackground();
removeIndicator(this.mErrorView);
this.mErrorView = null;
}
this.mErrorEnabled = enabled;
}
}
示例2: ToolbarProgressBar
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Creates a toolbar progress bar.
*
* @param context the application environment.
* @param attrs the xml attributes that should be used to initialize this view.
*/
public ToolbarProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
setAlpha(0.0f);
// This tells accessibility services that progress bar changes are important enough to
// announce to the user even when not focused.
ViewCompat.setAccessibilityLiveRegion(this, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
}
示例3: SnackbarLayout
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public SnackbarLayout(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
this.mMaxWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_android_maxWidth, -1);
this.mMaxInlineActionWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_maxActionInlineWidth, -1);
if (a.hasValue(R.styleable.SnackbarLayout_elevation)) {
ViewCompat.setElevation(this, (float) a.getDimensionPixelSize(R.styleable.SnackbarLayout_elevation, 0));
}
a.recycle();
setClickable(true);
LayoutInflater.from(context).inflate(R.layout.design_layout_snackbar_include, this);
ViewCompat.setAccessibilityLiveRegion(this, 1);
ViewCompat.setImportantForAccessibility(this, 1);
}
示例4: BaseTransientBottomBar
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* Constructor for the transient bottom bar.
*
* @param parent The parent for this transient bottom bar.
* @param content The content view for this transient bottom bar.
* @param contentViewCallback The content view callback for this transient bottom bar.
*/
protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content,
@NonNull ContentViewCallback contentViewCallback) {
if (parent == null) {
throw new IllegalArgumentException("Transient bottom bar must have non-null parent");
}
if (content == null) {
throw new IllegalArgumentException("Transient bottom bar must have non-null content");
}
if (contentViewCallback == null) {
throw new IllegalArgumentException("Transient bottom bar must have non-null callback");
}
mTargetParent = parent;
mContentViewCallback = contentViewCallback;
mContext = parent.getContext();
// ThemeUtils.checkAppCompatTheme(mContext);
LayoutInflater inflater = LayoutInflater.from(mContext);
// Note that for backwards compatibility reasons we inflate a layout that is defined
// in the extending Snackbar class. This is to prevent breakage of apps that have custom
// coordinator layout behaviors that depend on that layout.
mView = (SnackbarBaseLayout) inflater.inflate(
R.layout.design_layout_snackbar, mTargetParent, false);
mView.addView(content);
ViewCompat.setAccessibilityLiveRegion(mView,
ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
ViewCompat.setImportantForAccessibility(mView,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
// Make sure that we fit system windows and have a listener to apply any insets
ViewCompat.setFitsSystemWindows(mView, true);
ViewCompat.setOnApplyWindowInsetsListener(mView,
new android.support.v4.view.OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View v,
WindowInsetsCompat insets) {
// Copy over the bottom inset as padding so that we're displayed
// above the navigation bar
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(),
v.getPaddingRight(), insets.getSystemWindowInsetBottom());
return insets;
}
});
mAccessibilityManager = (AccessibilityManager)
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}