Java Code Examples for android.view.View#setVisibility()
The following examples show how to use
android.view.View#setVisibility() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DidiLayout.java From DidiLayout with Apache License 2.0 | 5 votes |
void updateObscuredViewVisibility() { if (getChildCount() == 0) { return; } final int leftBound = getPaddingLeft(); final int rightBound = getWidth() - getPaddingRight(); final int topBound = getPaddingTop(); final int bottomBound = getHeight() - getPaddingBottom(); final int left; final int right; final int top; final int bottom; if (mSlideableView != null && hasOpaqueBackground(mSlideableView)) { left = mSlideableView.getLeft(); right = mSlideableView.getRight(); top = mSlideableView.getTop(); bottom = mSlideableView.getBottom(); } else { left = right = top = bottom = 0; } View child = getChildAt(0); final int clampedChildLeft = Math.max(leftBound, child.getLeft()); final int clampedChildTop = Math.max(topBound, child.getTop()); final int clampedChildRight = Math.min(rightBound, 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 2
Source File: AnimatorUtil.java From diycode with Apache License 2.0 | 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 3
Source File: SearchPlaceActivity.java From Expert-Android-Programming with MIT License | 5 votes |
private void hideBottom(final View view, Animator.AnimatorListener listener) { view.setVisibility(View.VISIBLE); Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0f, view.getHeight()), PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f)); iconAnim.setDuration(VIEW_ANIMATION); iconAnim.addListener(listener); iconAnim.start(); }
Example 4
Source File: ContentController.java From ForPDA with GNU General Public License v3.0 | 5 votes |
public void showContent(Object tag) { View view = contents.get(tag); if (view != null) { view.setVisibility(View.VISIBLE); //mainContent.setVisibility(View.GONE); } }
Example 5
Source File: BodyElementBaseButton.java From RedReader with GNU General Public License v3.0 | 5 votes |
@Override public final View generateView( @NonNull final AppCompatActivity activity, @Nullable final Integer textColor, @Nullable final Float textSize, final boolean showLinkButtons) { if(mIsLinkButton && !showLinkButtons) { // Don't show final View result = new View(activity); result.setVisibility(View.GONE); return result; } final LinkDetailsView ldv = new LinkDetailsView( activity, mText, mSubtitle); final int linkMarginPx = General.dpToPixels(activity, 8); final ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, linkMarginPx, 0, linkMarginPx); ldv.setLayoutParams(layoutParams); ldv.setOnClickListener( generateOnClickListener(activity, textColor, textSize, showLinkButtons)); final View.OnLongClickListener longClickListener = generateOnLongClickListener(activity, textColor, textSize, showLinkButtons); if(longClickListener != null) { ldv.setOnLongClickListener(longClickListener); } return ldv; }
Example 6
Source File: SystemBarTintManager.java From Android-SpeedyViewSelector with Apache License 2.0 | 5 votes |
private void setupStatusBarView(Context context, ViewGroup decorViewGroup) { mStatusBarTintView = new View(context); LinearLayout.LayoutParams params = generateLayoutParams(LinearLayout.LayoutParams.MATCH_PARENT , mConfig.getStatusBarHeight(),0); if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) { params.rightMargin = mConfig.getNavigationBarWidth(); } mStatusBarTintView.setLayoutParams(params); mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR); mStatusBarTintView.setVisibility(View.GONE); decorViewGroup.addView(mStatusBarTintView); }
Example 7
Source File: ResideLayout.java From ResideLayout with Apache License 2.0 | 5 votes |
void setAllChildrenVisible() { for (int i = 0, childCount = getChildCount(); i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == INVISIBLE) { child.setVisibility(VISIBLE); } } }
Example 8
Source File: SlidingUpPanelLayout.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
void setAllChildrenVisible() { int i = getChildCount(); for (int j = 0; j < i; j++) { View view = getChildAt(j); if (view.getVisibility() == 4) { view.setVisibility(0); } } }
Example 9
Source File: NiftyDialogBuilder.java From quickmark with MIT License | 5 votes |
private void toggleView(View view,Object obj){ if (obj==null){ view.setVisibility(View.GONE); }else { view.setVisibility(View.VISIBLE); } }
Example 10
Source File: IrrigationZoneListAdapter.java From arcusandroid with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ListItemModel item = getItem(position); if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.lng_zone_device_item, parent, false); } View itemView = convertView.findViewById(R.id.normal_item_container); View headingView = convertView.findViewById(R.id.heading_item_continer); if (item.isHeadingRow()) { itemView.setVisibility(View.GONE); headingView.setVisibility(View.VISIBLE); return getViewForHeading(item, convertView); } else { itemView.setVisibility(View.VISIBLE); headingView.setVisibility(View.GONE); boolean nextRowIsHeader = false; boolean isLastRow = false; try { nextRowIsHeader = getItem(position + 1).isHeadingRow(); } catch (Exception ignored) { isLastRow = true; } return getViewForNonHeader(item, convertView, nextRowIsHeader, isLastRow); } }
Example 11
Source File: ViewHolder.java From OpenEyes with Apache License 2.0 | 5 votes |
/** * 设置控件是否可见 * @param viewId * @param visible * @return */ public ViewHolder setVisible(int viewId, boolean visible) { View view = getView(viewId); view.setVisibility(visible ? View.VISIBLE : View.GONE); return this; }
Example 12
Source File: MainActivity.java From android-basic-samples with Apache License 2.0 | 5 votes |
/** * Dismisses the previously displayed alert message. */ private void hideAlertBar() { View alertBar = findViewById(R.id.alert_bar); if (alertBar != null && alertBar.getVisibility() != View.GONE) { alertBar.setVisibility(View.GONE); } }
Example 13
Source File: DirectoryAdapter.java From nitroshare-android with MIT License | 4 votes |
@NonNull @Override public View getView(final int position, View convertView, @NonNull ViewGroup parent) { View view = super.getView(position, convertView, parent); File file = getItem(position); //noinspection ConstantConditions ((TextView) view.findViewById(android.R.id.text1)).setText(file.getName()); ((TextView) view.findViewById(android.R.id.text2)).setText( file.isDirectory() ? getDirectorySummary(file) : getFileSummary(file) ); ((TextView) view.findViewById(R.id.last_modified)).setText( DateUtils.getRelativeDateTimeString( mContext, file.lastModified(), DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0 ) ); final ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); imageView.setColorFilter(mColor); Picasso.with(mContext) .load(file) .resizeDimen(R.dimen.explorer_icon_size, R.dimen.explorer_icon_size) .centerCrop() .placeholder(ContextCompat.getDrawable( mContext, file.isDirectory() ? R.drawable.ic_folder : R.drawable.ic_file )) .into(imageView, new Callback() { @Override public void onSuccess() { // Remove the tint once the image loads imageView.setColorFilter(Color.argb(0, 0, 0, 0), PorterDuff.Mode.DST); } @Override public void onError() { } }); View spacer = view.findViewById(R.id.spacer); CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox); if (mCheckboxes) { checkBox.setOnCheckedChangeListener(null); checkBox.setChecked(mChecked.indexOfKey(position) >= 0); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mChecked.put(position, getItem(position)); } else { mChecked.remove(position); if (mChecked.size() == 0) { mListener.onAllItemsDeselected(); } } } }); spacer.setVisibility(View.VISIBLE); checkBox.setVisibility(View.VISIBLE); } else { spacer.setVisibility(View.GONE); checkBox.setVisibility(View.GONE); } return view; }
Example 14
Source File: ProjectAdapter.java From microbit with Apache License 2.0 | 4 votes |
/** * Sets editTextView visible and project button invisible. * * @param v Edit text view. */ private void showEditTextView(View v) { Button bt = (Button) v.getTag(R.id.editbutton); bt.setVisibility(View.INVISIBLE); v.setVisibility(View.VISIBLE); }
Example 15
Source File: CoolDragAndDropGridView.java From UltimateAndroid with Apache License 2.0 | 4 votes |
private void onDrop() { destroyDragImageView(); removeCallbacks(mDelayedOnDragRunnable); View v = getChildAt(mDropPosition); v.setVisibility(View.VISIBLE); v.clearAnimation(); if (mDragAndDropListener != null && mDropPosition != AdapterView.INVALID_POSITION) { mDragAndDropListener.onDropItem(mDragPosition, mDropPosition); } mDragPosition = mDropPosition = mCurrentPosition = AdapterView.INVALID_POSITION; mDragAndDropStarted = false; }
Example 16
Source File: ViewUtils.java From Cotable with Apache License 2.0 | 4 votes |
public static void a(View view, int i) { if (view != null) view.setVisibility(i); }
Example 17
Source File: ViewHelper.java From DMusic with Apache License 2.0 | 4 votes |
/** * 批量设置View visibility */ public static void setViewVisibility(int visibility, View... views) { for (View v : views) { v.setVisibility(visibility); } }
Example 18
Source File: SocialDetailActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
private void setCommentTextClick(TextView mTextView2, JSONArray data, View view, int goodSize) { if (goodSize > 0 && data.size() > 0) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } if (data.size() == 0) { mTextView2.setVisibility(View.GONE); } else { mTextView2.setVisibility(View.VISIBLE); } SpannableStringBuilder ssb = new SpannableStringBuilder(); int start = 0; for (int i = 0; i < data.size(); i++) { JSONObject json = data.getJSONObject(i); String content = json.getString("content"); String scID = json.getString("scID"); String userID_temp = json.getString("userID"); String nick = userID_temp; if (userID_temp.equals(myuserID)) { nick = myNick; } else { User user = MYApplication.getInstance().getContactList() .get(userID_temp); if (user != null) { nick = user.getNick(); } } String content_0 = ""; String content_1 = ": " + content; String content_2 = ": " + content + "\n"; if (i == (data.size() - 1) || (data.size() == 1 && i == 0)) { ssb.append(nick + content_1); content_0 = content_1; } else { ssb.append(nick + content_2); content_0 = content_2; } ssb.setSpan(new TextViewURLSpan(nick, userID_temp, 1), start, start + nick.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (userID_temp.equals(myuserID)) { ssb.setSpan(new TextViewURLSpan(nick, userID_temp, i, scID, 2, mTextView2, data, view, goodSize), start, start + nick.length() + content_0.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } start = ssb.length(); } mTextView2.setText(ssb); mTextView2.setMovementMethod(LinkMovementMethod.getInstance()); }
Example 19
Source File: BindingAdapterUtils.java From xDrip with GNU General Public License v3.0 | 4 votes |
@BindingAdapter(value = {"showIfTrueInRecycler"}, requireAll = true) public static void setShowIfTrueInRecycler(@NonNull View view, boolean isVisible) { view.setVisibility(isVisible ? View.VISIBLE : View.GONE); view.getLayoutParams().height = isVisible ? LinearLayout.LayoutParams.WRAP_CONTENT : 0; }
Example 20
Source File: ListViewFilterActivity.java From UltimateAndroid with Apache License 2.0 | 4 votes |
private void showContent(View contentView, View loadingView, View emptyView) { contentView.setVisibility(View.VISIBLE); loadingView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); }