android.support.v4.view.ViewCompat#setAccessibilityLiveRegion ( )源码实例Demo

下面列出了android.support.v4.view.ViewCompat#setAccessibilityLiveRegion ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Floaty   文件: Floaty.java
private Floaty(ViewGroup parent, View content) {
    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");
    }

    targetParent = parent;
    context = parent.getContext();
    view = (FloatyContentLayout) content;

    stage = Stage.of(targetParent);

    ViewCompat.setAccessibilityLiveRegion(stage, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(stage, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    stage.setFitsSystemWindows(true);
    ViewCompat.setOnApplyWindowInsetsListener(stage,
            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;
                }
            });

    accessibilityManager =
            (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    scene = new Scene(stage, view);
}
 
源代码2 项目: SweetTips   文件: SweetSnackbar.java
public SnackbarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_android_maxWidth, -1);
    mMaxInlineActionWidth = a.getDimensionPixelSize(
            R.styleable.SnackbarLayout_maxActionInlineWidth, -1);
    if (a.hasValue(R.styleable.SnackbarLayout_elevation)) {
        ViewCompat.setElevation(this, a.getDimensionPixelSize(
                R.styleable.SnackbarLayout_elevation, 0));
    }
    a.recycle();

    setClickable(true);

    // Now inflate our content. We need to do this manually rather than using an <include>
    // in the layout since older versions of the Android do not inflate includes with
    // the correct Context.
    LayoutInflater.from(context).inflate(com.jet.sweettips.R.layout.sweet_layout_snackbar_include, this);

    ViewCompat.setAccessibilityLiveRegion(this,
            ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(this,
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(this, true);
    ViewCompat.setOnApplyWindowInsetsListener(this,
            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;
        }
    });
}
 
源代码3 项目: delion   文件: ToolbarProgressBar.java
/**
 * 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);
}
 
源代码4 项目: AndroidChromium   文件: ToolbarProgressBar.java
/**
 * 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);
}
 
源代码5 项目: SweetTips   文件: SweetSnackbar.java
public SnackbarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_android_maxWidth, -1);
    mMaxInlineActionWidth = a.getDimensionPixelSize(
            R.styleable.SnackbarLayout_maxActionInlineWidth, -1);
    if (a.hasValue(R.styleable.SnackbarLayout_elevation)) {
        ViewCompat.setElevation(this, a.getDimensionPixelSize(
                R.styleable.SnackbarLayout_elevation, 0));
    }
    a.recycle();

    setClickable(true);

    // Now inflate our content. We need to do this manually rather than using an <include>
    // in the layout since older versions of the Android do not inflate includes with
    // the correct Context.
    LayoutInflater.from(context).inflate(com.jet.sweettips.R.layout.sweet_layout_snackbar_include, this);

    ViewCompat.setAccessibilityLiveRegion(this,
            ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(this,
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(this, true);
    ViewCompat.setOnApplyWindowInsetsListener(this,
            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;
        }
    });
}
 
源代码6 项目: 365browser   文件: ToolbarProgressBar.java
/**
 * Creates a toolbar progress bar.
 *
 * @param context The application environment.
 * @param height The height of the progress bar in px.
 * @param topMargin The top margin of the progress bar.
 * @param useStatusBarColorAsBackground Whether or not to use the status bar color as the
 *                                      background of the toolbar.
 */
public ToolbarProgressBar(
        Context context, int height, int topMargin, boolean useStatusBarColorAsBackground) {
    super(context, height);
    setAlpha(0.0f);
    mMarginTop = topMargin;
    mUseStatusBarColorAsBackground = useStatusBarColorAsBackground;

    // 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);
}
 
 同类方法