Java Code Examples for android.view.View.setVisibility()

The following are Jave code examples for showing how to use setVisibility() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: RRFramework-Android   File: RootFrameLayout.java   View Source Code Vote up 6 votes
/**
 *  根据ID显示隐藏布局
 * @param id
 */
private void showHideViewById(int id) {
    for (int i = 0; i < layoutSparseArray.size(); i++) {
        int key = layoutSparseArray.keyAt(i);
        View valueView = layoutSparseArray.valueAt(i);
        //显示该view
        if(key == id) {
            valueView.setVisibility(View.VISIBLE);
            if(mStatusLayoutManager.onShowHideViewListener != null) mStatusLayoutManager.onShowHideViewListener.onShowView(valueView, key);
        } else {
            if(valueView.getVisibility() != View.GONE) {
                valueView.setVisibility(View.GONE);
                if(mStatusLayoutManager.onShowHideViewListener != null) mStatusLayoutManager.onShowHideViewListener.onHideView(valueView, key);
            }
        }
    }
}
 
Example 2
Project: PaoMovie   File: MoreWindow.java   View Source Code Vote up 6 votes
private void showAnimation(ViewGroup layout){
	for(int i=0;i<layout.getChildCount();i++){
		final View child = layout.getChildAt(i);
		if(child.getId() == R.id.popmenu_close){
			continue;
		}
		child.setOnClickListener(this);
		child.setVisibility(View.INVISIBLE);
		mHandler.postDelayed(new Runnable() {
			
			@Override
			public void run() {
				child.setVisibility(View.VISIBLE);
				ValueAnimator fadeAnim = ObjectAnimator.ofFloat(child, "translationY", 600, 0);
				fadeAnim.setDuration(300);
				KickBackAnimator kickAnimator = new KickBackAnimator();
				kickAnimator.setDuration(150);
				fadeAnim.setEvaluator(kickAnimator);
				fadeAnim.start();
			}
		}, i * 50);
	}
	
}
 
Example 3
Project: OpenHomeAnalysis   File: OhaDatePickerDialogPreference.java   View Source Code Vote up 6 votes
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);
    this.datePicker = (DatePicker) view.findViewById(R.id.datePicker);
    //Remover o date_picker_header do datePicker se o mesmo existir
    View viewDayDatePicker = datePicker.findViewById(Resources.getSystem().getIdentifier("date_picker_header", "id", "android"));
    if (viewDayDatePicker != null) {
        viewDayDatePicker.setVisibility(View.GONE);
    }
    Calendar calendar = Calendar.getInstance();
    try {
        //recuperar a preferência no formato yyyyMMdd e converter para um Calendar:
        calendar = OhaHelper.getCalendar(this.getPersistedString(OhaHelper.getStrDate(new Date())));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    datePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), null);
}
 
Example 4
Project: BottomMenu   File: BottomMenu.java   View Source Code Vote up 6 votes
private void layoutChildItems() {
    int count = getChildCount();
    double baseAngle = (Math.PI - mItemAngleSection) / 2;
    for (int i = 1; i < count; i++) {
        View child = getChildAt(i);
        int cWidth = child.getMeasuredWidth();
        int cHeight = child.getMeasuredHeight();

        int l = (int) (getMeasuredWidth() / 2 - mRadius * Math.cos(mItemAngleSection / count * i + baseAngle) - cWidth / 2);
        int t = (int) (getMeasuredHeight() - (mRadius * Math.sin(mItemAngleSection / count * i + baseAngle) - mPointOffetScreenY)
                - mMarginBottom);

        child.layout(l, t, l + cWidth, t + cHeight);
        child.setVisibility(View.GONE);
    }
}
 
Example 5
Project: BookReader-master   File: BaseActivity.java   View Source Code Vote up 5 votes
protected void visible(final View... views) {
    if (views != null && views.length > 0) {
        for (View view : views) {
            if (view != null) {
                view.setVisibility(View.VISIBLE);
            }
        }
    }

}
 
Example 6
Project: ClouldReader   File: XRecyclerView.java   View Source Code Vote up 5 votes
public void noMoreLoading() {
    isLoadingData = false;
    final View footView = mFootViews.get(0);
    isnomore = true;
    if (footView instanceof LoadingMoreFooter) {
        ((LoadingMoreFooter) footView).setState(LoadingMoreFooter.STATE_NOMORE);
    } else {
        footView.setVisibility(View.GONE);
    }
    // 额外添加的footView
    if (isOther) {
        footView.setVisibility(View.VISIBLE);
    }
}
 
Example 7
Project: Sega   File: SearchAnimator.java   View Source Code Vote up 5 votes
static void fadeIn(View view, int duration) {
    Animation anim = new AlphaAnimation(0.0f, 1.0f);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setDuration(duration);

    view.setAnimation(anim);
    view.setVisibility(View.VISIBLE);
}
 
Example 8
Project: HeadlineNews   File: BarUtils.java   View Source Code Vote up 5 votes
private static void addStatusBarColor(final Activity activity, final int color, final int alpha, boolean isDecor) {
    ViewGroup parent = isDecor ?
            (ViewGroup) activity.getWindow().getDecorView() :
            (ViewGroup) activity.findViewById(android.R.id.content);
    View fakeStatusBarView = parent.findViewWithTag(TAG_COLOR);
    if (fakeStatusBarView != null) {
        if (fakeStatusBarView.getVisibility() == View.GONE) {
            fakeStatusBarView.setVisibility(View.VISIBLE);
        }
        fakeStatusBarView.setBackgroundColor(getStatusBarColor(color, alpha));
    } else {
        parent.addView(createColorStatusBarView(parent.getContext(), color, alpha));
    }
}
 
Example 9
Project: AppLockLibrary   File: LockActivity.java   View Source Code Vote up 5 votes
private void initViews() {
    mFingerprintImageView = (View) findViewById(R.id.fingerprint_image);

    if (isFingerPrintLockEnabled) {
        mFingerprintImageView.setVisibility(View.VISIBLE);
    }
    else {
        mFingerprintImageView.setVisibility(View.GONE);
    }
    mPatternLockView = (PatternLockView) findViewById(R.id.pattern_lock_view);
}
 
Example 10
Project: Mix   File: AnimatorUtil.java   View Source Code Vote up 5 votes
public static void scaleShow(View view, ViewPropertyAnimatorListener viewPropertyAnimatorListener) {
    view.setVisibility(View.VISIBLE);
    ViewCompat.animate(view)
            .scaleX(1.0f)
            .scaleY(1.0f)
            .alpha(1.0f)
            .setDuration(800)
            .setListener(viewPropertyAnimatorListener)
            .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR)
            .start();
}
 
Example 11
Project: pipe   File: EmptyView.java   View Source Code Vote up 5 votes
/**
 * 更改绑定布局的显示状态
 *
 * @param visible 显示的状态
 */
private void changeBindViewVisibility(int visible) {
    final View[] views = mBindViews;
    if (views == null || views.length == 0)
        return;

    for (View view : views) {
        view.setVisibility(visible);
    }
}
 
Example 12
Project: oma-riista-android   File: GameCalendar.java   View Source Code Vote up 5 votes
public void setCategories(SparseArray<SpeciesCategory> categories, SparseIntArray categoryData) {
    LinearLayout categoriesView = (LinearLayout) findViewById(R.id.categories);
    categoriesView.removeAllViews();
    for (int i = 0; i < SpeciesInformation.getSpeciesCategories().size() && i < DISPLAY_CATEGORIES; i++) {
        CatchCategoryItem item = new CatchCategoryItem(mContext);
        SpeciesCategory speciesCategory = categories.get(categories.keyAt(i));
        item.setContents(categoryData.get(speciesCategory.mId), speciesCategory.mName);
        item.setLayoutParams(new CatchCategoryItem.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
        if (i < DISPLAY_CATEGORIES - 1) {
            View separator = item.findViewById(R.id.divider);
            separator.setVisibility(View.VISIBLE);
        }
        categoriesView.addView(item);
    }
}
 
Example 13
Project: BBSSDK-for-Android   File: Theme0ForumForumView.java   View Source Code Vote up 5 votes
protected void calcAndRefreshStickTopView() {
	Collections.sort(listStickTop, new Comparator<ForumForum>() {
		@Override
		public int compare(ForumForum lhs, ForumForum rhs) {
			return new Long(lhs.fid - rhs.fid).intValue();
		}
	});
	//Reuse the view created last time.
	for (int i = 0; i < listStickTop.size(); i++) {
		View viewchild = layoutSticktop.getChildAt(i);
		View view = createSticktopItem(listStickTop.get(i), viewchild, layoutSticktop);
		view.setVisibility(VISIBLE);
		if(viewchild == null) {
			layoutSticktop.addView(view);
		}
	}
	int childcount = layoutSticktop.getChildCount();
	if(childcount > listStickTop.size()) {
		for(int i = listStickTop.size(); i < childcount; i++) {
			layoutSticktop.getChildAt(i).setVisibility(GONE);
		}
	}

	if (layoutSticktop.getChildCount() == 0) {
		layoutSticktop.setVisibility(View.GONE);
	} else {
		layoutSticktop.setVisibility(VISIBLE);
	}
}
 
Example 14
Project: KUtils   File: SystemBarTintManager.java   View Source Code Vote up 5 votes
private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
    mStatusBarTintView = new View(context);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
    params.gravity = Gravity.TOP;
    if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
        params.rightMargin = mConfig.getNavigationBarWidth();
    }
    mStatusBarTintView.setLayoutParams(params);
    mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
    mStatusBarTintView.setVisibility(View.GONE);
    decorViewGroup.addView(mStatusBarTintView);
}
 
Example 15
Project: q-mail   File: ICalendarPublishView.java   View Source Code Vote up 5 votes
private void updateField(TextView v, CharSequence text, View label) {
    boolean hasText = !TextUtils.isEmpty(text);

    v.setText(text);
    v.setVisibility(hasText ? View.VISIBLE : View.GONE);
    label.setVisibility(hasText ? View.VISIBLE : View.GONE);
}
 
Example 16
Project: WechatChatroomHelper   File: BGASwipeBackLayout.java   View Source Code Vote up 4 votes
void updateObscuredViewsVisibility(View panel) {
    final boolean isLayoutRtl = isLayoutRtlSupport();
    final int startBound = isLayoutRtl ? (getWidth() - getPaddingRight()) : getPaddingLeft();
    final int endBound = isLayoutRtl ? getPaddingLeft() : (getWidth() - getPaddingRight());
    final int topBound = getPaddingTop();
    final int bottomBound = getHeight() - getPaddingBottom();
    final int left;
    final int right;
    final int top;
    final int bottom;
    if (panel != null && viewIsOpaque(panel)) {
        left = panel.getLeft();
        right = panel.getRight();
        top = panel.getTop();
        bottom = panel.getBottom();
    } else {
        left = right = top = bottom = 0;
    }

    for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
        final View child = getChildAt(i);

        if (child == panel) {
            // There are still more children above the panel but they won't be affected.
            break;
        } else if (child.getVisibility() == GONE) {
            continue;
        }

        final int clampedChildLeft = Math.max(
                (isLayoutRtl ? endBound : startBound), child.getLeft());
        final int clampedChildTop = Math.max(topBound, child.getTop());
        final int clampedChildRight = Math.min(
                (isLayoutRtl ? startBound : endBound), child.getRight());
        final int clampedChildBottom = Math.min(bottomBound, child.getBottom());
        final int vis;
        if (clampedChildLeft >= left && clampedChildTop >= top
                && clampedChildRight <= right && clampedChildBottom <= bottom) {
            vis = INVISIBLE;
        } else {
            vis = VISIBLE;
        }
        child.setVisibility(vis);
    }
}
 
Example 17
Project: Phoenix-for-VK   File: AttachmentsViewBinder.java   View Source Code Vote up 4 votes
private static void safeSetVisibitity(@Nullable View view, int visibility) {
    if (view != null) view.setVisibility(visibility);
}
 
Example 18
Project: FlickLauncher   File: AllAppsContainerView.java   View Source Code Vote up 4 votes
/**
 * Update the background and padding of the Apps view and children.  Instead of insetting the
 * container view, we inset the background and padding of the recycler view to allow for the
 * recycler view to handle touch events (for fast scrolling) all the way to the edge.
 */
private void updatePaddingsAndMargins(int widthPx, int heightPx) {
    Rect bgPadding = new Rect();
    getRevealView().getBackground().getPadding(bgPadding);

    mAppsRecyclerView.updateBackgroundPadding(bgPadding);
    mAdapter.updateBackgroundPadding(bgPadding);
    mElevationController.updateBackgroundPadding(bgPadding);

    // Pad the recycler view by the background padding plus the start margin (for the section
    // names)
    int maxScrollBarWidth = mAppsRecyclerView.getMaxScrollbarWidth();
    int startInset = Math.max(mSectionNamesMargin, maxScrollBarWidth);
    if (Utilities.isRtl(getResources())) {
        mAppsRecyclerView.setPadding(bgPadding.left + maxScrollBarWidth, 0, bgPadding.right
                + startInset, mRecyclerViewBottomPadding);
    } else {
        mAppsRecyclerView.setPadding(bgPadding.left + startInset, 0, bgPadding.right +
                maxScrollBarWidth, mRecyclerViewBottomPadding);
    }

    MarginLayoutParams lp = (MarginLayoutParams) mSearchContainer.getLayoutParams();
    lp.leftMargin = bgPadding.left;
    lp.rightMargin = bgPadding.right;

    // Clip the view to the left and right edge of the background to
    // to prevent shadows from rendering beyond the edges
    final Rect newClipBounds = new Rect(
            bgPadding.left, 0, widthPx - bgPadding.right, heightPx);
    setClipBounds(newClipBounds);

    // Allow the overscroll effect to reach the edges of the view
    mAppsRecyclerView.setClipToPadding(false);

    DeviceProfile grid = mLauncher.getDeviceProfile();
    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
        if (!grid.isVerticalBarLayout()) {
            MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams();

            Rect insets = mLauncher.getDragLayer().getInsets();
            getContentView().setPadding(0, 0, 0, 0);
            int height = insets.top + grid.hotseatCellHeightPx;

            mlp.topMargin = height;
            mAppsRecyclerView.setLayoutParams(mlp);

            mSearchContainer.setPadding(
                    mSearchContainer.getPaddingLeft(),
                    insets.top + mSearchContainerOffsetTop,
                    mSearchContainer.getPaddingRight(),
                    mSearchContainer.getPaddingBottom());
            lp.height = height;

            View navBarBg = findViewById(R.id.nav_bar_bg);
            ViewGroup.LayoutParams params = navBarBg.getLayoutParams();
            params.height = insets.bottom;
            navBarBg.setLayoutParams(params);
            navBarBg.setVisibility(View.VISIBLE);
        }
    }
    mSearchContainer.setLayoutParams(lp);
}
 
Example 19
Project: Renrentou   File: VDelegateBase.java   View Source Code Vote up 4 votes
@Override
public void inVisible(View view) {
    view.setVisibility(View.INVISIBLE);
}
 
Example 20
Project: CustomAndroidOneSheeld   File: MultiDirectionSlidingDrawer.java   View Source Code Vote up 4 votes
private void prepareContent() {
    if (mAnimating) {
        return;
    }

    // Something changed in the content, we need to honor the layout request
    // before creating the cached bitmap
    final View content = mContent;
    if (content.isLayoutRequested()) {

        if (mVertical) {
            final int handleHeight = mHandleHeight;
            int height = getBottom() - getTop() - handleHeight - mTopOffset;
            content.measure(MeasureSpec.makeMeasureSpec(getRight()
                    - getLeft(), MeasureSpec.EXACTLY), MeasureSpec
                    .makeMeasureSpec(height, MeasureSpec.EXACTLY));

            Log.d(LOG_TAG, "content.layout(2)");

            if (mInvert)
                content.layout(0, mTopOffset, content.getMeasuredWidth(),
                        mTopOffset + content.getMeasuredHeight());
            else
                content.layout(
                        0,
                        mTopOffset + handleHeight,
                        content.getMeasuredWidth(),
                        mTopOffset + handleHeight
                                + content.getMeasuredHeight());

        } else {

            final int handleWidth = mHandle.getWidth();
            int width = getRight() - getLeft() - handleWidth - mTopOffset;
            content.measure(MeasureSpec.makeMeasureSpec(width,
                    MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(
                    getBottom() - getTop(), MeasureSpec.EXACTLY));

            if (mInvert)
                content.layout(mTopOffset, 0,
                        mTopOffset + content.getMeasuredWidth(),
                        content.getMeasuredHeight());
            else
                content.layout(handleWidth + mTopOffset, 0, mTopOffset
                                + handleWidth + content.getMeasuredWidth(),
                        content.getMeasuredHeight());
        }
    }
    // Try only once... we should really loop but it's not a big deal
    // if the draw was cancelled, it will only be temporary anyway
    content.getViewTreeObserver().dispatchOnPreDraw();
    content.buildDrawingCache();

    content.setVisibility(View.GONE);
}