當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.setVisible方法代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable.setVisible方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setVisible方法的具體用法?Java Drawable.setVisible怎麽用?Java Drawable.setVisible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.Drawable的用法示例。


在下文中一共展示了Drawable.setVisible方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: copyViewAsImage

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private ImageView copyViewAsImage(View v) {
    //Clear ripple effect to not get into screenshot,
    // need something more clever here
    if (v instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) v;
        Drawable foreground = frameLayout.getForeground();
        if (foreground != null) foreground.setVisible(false, false);
    } else {
        if (v.getBackground() != null) v.getBackground().setVisible(false, false);
    }


    Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);

    //Drag highlight, usually border
    if (dragHighlight != null) {
        dragHighlight.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
        dragHighlight.draw(canvas);
    }

    ImageView imageView = new ImageView(recyclerView.getContext());
    imageView.setImageBitmap(bitmap);
    return imageView;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:DragDropTouchListener.java

示例2: testMockDrawable_VisibilityCallback

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Test
public void testMockDrawable_VisibilityCallback() {
  boolean reset = true;
  Drawable drawable = DrawableTestUtils.mockDrawable();
  assertTrue(drawable instanceof VisibilityAwareDrawable);

  VisibilityAwareDrawable visibilityAwareDrawable = (VisibilityAwareDrawable) drawable;
  VisibilityCallback visibilityCallback = mock(VisibilityCallback.class);
  visibilityAwareDrawable.setVisibilityCallback(visibilityCallback);

  InOrder inOrder = inOrder(visibilityCallback);
  drawable.setVisible(false, reset);
  inOrder.verify(visibilityCallback).onVisibilityChange(false);
  drawable.setVisible(true, reset);
  inOrder.verify(visibilityCallback).onVisibilityChange(true);
  drawable.setVisible(false, reset);
  inOrder.verify(visibilityCallback).onVisibilityChange(false);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:DraweeMocksTest.java

示例3: setViewDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Sets the drawable in an image view, makes sure the view is only visible if there
 * is a drawable.
 */
private void setViewDrawable(ImageView v, Drawable drawable, int nullVisibility) {
    // Set the icon even if the drawable is null, since we need to clear any
    // previous icon.
    v.setImageDrawable(drawable);

    if (drawable == null) {
        v.setVisibility(nullVisibility);
    } else {
        v.setVisibility(View.VISIBLE);

        // This is a hack to get any animated drawables (like a 'working' spinner)
        // to animate. You have to setVisible true on an AnimationDrawable to get
        // it to start animating, but it must first have been false or else the
        // call to setVisible will be ineffective. We need to clear up the story
        // about animated drawables in the future, see http://b/1878430.
        drawable.setVisible(false, false);
        drawable.setVisible(true, false);
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:24,代碼來源:SuggestionsAdapter.java

示例4: positionSelectorLikeFocusCompat

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
protected void positionSelectorLikeFocusCompat(int position, View sel) {
    boolean manageState;
    boolean z = true;
    Drawable selector = getSelector();
    if (selector == null || position == -1) {
        manageState = false;
    } else {
        manageState = true;
    }
    if (manageState) {
        selector.setVisible(false, false);
    }
    positionSelectorCompat(position, sel);
    if (manageState) {
        Rect bounds = this.mSelectorRect;
        float x = bounds.exactCenterX();
        float y = bounds.exactCenterY();
        if (getVisibility() != 0) {
            z = false;
        }
        selector.setVisible(z, false);
        DrawableCompat.setHotspot(selector, x, y);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:ListViewCompat.java

示例5: setWrappedDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public final void setWrappedDrawable(Drawable dr) {
    if (this.mDrawable != null) {
        this.mDrawable.setCallback(null);
    }
    this.mDrawable = dr;
    if (dr != null) {
        dr.setCallback(this);
        dr.setVisible(isVisible(), true);
        dr.setState(getState());
        dr.setLevel(getLevel());
        dr.setBounds(getBounds());
        if (this.mState != null) {
            this.mState.mDrawableState = dr.getConstantState();
        }
    }
    invalidateSelf();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:DrawableWrapperDonut.java

示例6: maybeOverrideVisibilityHandling

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void maybeOverrideVisibilityHandling() {
  if (mLegacyVisibilityHandlingEnabled)  {
    Drawable drawable = getDrawable();
    if (drawable != null) {
      drawable.setVisible(getVisibility() == VISIBLE, false);
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:DraweeView.java

示例7: setVisible

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public boolean setVisible(boolean visible, boolean restart) {
  boolean changed = super.setVisible(visible, restart);
  for (int i = 0; i < mLayers.length; i++) {
    Drawable drawable = mLayers[i];
    if (drawable != null) {
      drawable.setVisible(visible, restart);
    }
  }
  return changed;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:ArrayDrawable.java

示例8: copyProperties

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Copies various properties from one drawable to the other.
 * @param to drawable to copy properties to
 * @param from drawable to copy properties from
 */
public static void copyProperties(Drawable to, Drawable from) {
  if (from == null || to == null || to == from) {
    return;
  }

  to.setBounds(from.getBounds());
  to.setChangingConfigurations(from.getChangingConfigurations());
  to.setLevel(from.getLevel());
  to.setVisible(from.isVisible(), /* restart */ false);
  to.setState(from.getState());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:DrawableUtils.java

示例9: setDaySelector

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Sets a drawable used to draw the selector highlighting the current selected day.
 *
 * @param selector The desired drawable for day selector. May be {@code null} to clear the current
 *                 one.
 * @see R.attr#uiMonthDaySelector ui:uiMonthDaySelector
 * @see #setDaySelectorTintList(ColorStateList)
 * @see #setDaySelectorTintMode(PorterDuff.Mode)
 * @see #getDaySelector()
 */
public void setDaySelector(@Nullable Drawable selector) {
	if (mDaySelector != selector) {
		final boolean needUpdate;
		if (mDaySelector != null) {
			mDaySelector.setCallback(null);
			unscheduleDrawable(mDaySelector);
			needUpdate = true;
		} else {
			needUpdate = false;
		}
		if (selector != null) {
			selector.setCallback(this);
			selector.setVisible(getVisibility() == VISIBLE, false);
		} else {
			this.mDaySelectorRes = 0;
		}
		this.mDaySelector = selector;
		this.applyDaySelectorTint();
		if (needUpdate) {
			if (mDaySelector.isStateful()) {
				mDaySelector.setState(getDrawableState());
			}
			invalidate();
		}
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:37,代碼來源:MonthView.java

示例10: setSelectionIndicator

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Sets the drawable used to draw the number selection indicator.
 *
 * @param indicator The desired drawable for selection indicator. May be {@code null} to clear
 *                  the current one.
 * @see R.attr#uiSelectionIndicator ui:uiSelectionIndicator
 * @see #setSelectionIndicatorTintList(ColorStateList)
 * @see #setSelectionIndicatorTintMode(PorterDuff.Mode)
 * @see #getSelectionIndicator()
 */
public void setSelectionIndicator(@Nullable Drawable indicator) {
	if (mSelectionIndicator != indicator) {
		final boolean needUpdate;
		if (mSelectionIndicator != null) {
			mSelectionIndicator.setCallback(null);
			unscheduleDrawable(mSelectionIndicator);
			needUpdate = true;
		} else {
			needUpdate = false;
		}

		if (indicator != null) {
			indicator.setCallback(this);
			indicator.setVisible(getVisibility() == VISIBLE, false);
			if (indicator.getPadding(mRect)) {
				TEXT_INFO.padding = Math.max(mRect.left, Math.max(mRect.top, Math.max(mRect.right, mRect.bottom)));
			}
		} else {
			this.mSelectionIndicatorRes = 0;
		}
		this.mSelectionIndicator = indicator;
		this.applySelectionIndicatorTint();
		if (needUpdate) {
			if (mSelectionIndicator.isStateful()) {
				mSelectionIndicator.setState(getDrawableState());
			}
			this.invalidateNumbersArea();
		}
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:41,代碼來源:CircularNumberPicker.java

示例11: updateDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void updateDrawable(Drawable d) {
        if (mDrawable != null) {
            mDrawable.setCallback(null);
            unscheduleDrawable(mDrawable);
            if (isAttachedWindow) {
                mDrawable.setVisible(false, false);
            }
        }
        mDrawable = d;

        if (d != null) {
            d.setCallback(this);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                d.setLayoutDirection(getLayoutDirection());
            }
            if (d.isStateful()) {
                d.setState(getDrawableState());
            }
            if (isAttachedWindow) {
                d.setVisible(getWindowVisibility() == VISIBLE && isShown(), true);
            }
            d.setLevel(mLevel);
            mDrawableWidth = d.getIntrinsicWidth();
            mDrawableHeight = d.getIntrinsicHeight();
//            applyImageTint();
//            applyColorMod();
//
//            configureBounds();
        } else {
            mDrawableWidth = mDrawableHeight = -1;
        }
    }
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:33,代碼來源:LargeImageView.java

示例12: updateDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void updateDrawable(Drawable d) {
        boolean sameDrawable = false;
        boolean sCompatDrawableVisibilityDispatch = false;

        if (mDrawable != null) {
            sameDrawable = mDrawable == d;
            mDrawable.setCallback(null);
            unscheduleDrawable(mDrawable);
            if (!sCompatDrawableVisibilityDispatch && !sameDrawable && isAttachedWindow) {
                mDrawable.setVisible(false, false);
            }
        }

        mDrawable = d;

        if (d != null) {
            d.setCallback(this);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                d.setLayoutDirection(getLayoutDirection());
            }
            if (d.isStateful()) {
                d.setState(getDrawableState());
            }
            if (!sameDrawable || sCompatDrawableVisibilityDispatch) {
                final boolean visible = sCompatDrawableVisibilityDispatch
                        ? getVisibility() == VISIBLE
                        : isAttachedWindow && getWindowVisibility() == VISIBLE && isShown();
                d.setVisible(visible, true);
            }
            d.setLevel(mLevel);
            mDrawableWidth = d.getIntrinsicWidth();
            mDrawableHeight = d.getIntrinsicHeight();
//            applyImageTint();
//            applyColorMod();
//
//            configureBounds();
        } else {
            mDrawableWidth = mDrawableHeight = -1;
        }
    }
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:41,代碼來源:UpdateImageView.java

示例13: hideCompoundDrawables

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void hideCompoundDrawables(Drawable[] drawables) {
	for (Drawable d : drawables) {
		if (d != null) {
			d.setVisible(false, false);
		}
	}
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:8,代碼來源:GifTextView.java

示例14: addDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * 添加drawable, 如果id已經存在, drawable將會被替換
 *
 * @param id       the drawable id.
 * @param drawable the drawable.
 * @return <code>true</code> - 如果添加成功, <code>false</code> - 其他
 */
public boolean addDrawable(int id, @NonNull Drawable drawable) {
    DrawableInfo old = findAvatarDrawableById(id);
    if (old != null) {
        Drawable d = old.mDrawable;
        old.mDrawable = drawable;
        if (!hasSameDrawable(d)) {
            cleanDrawable(d);
        }
        updateDrawableBounds(old);
    } else {
        if (getNumberOfDrawables() >= MAX_DRAWABLE_COUNT) {
            return false;
        }

        mDrawables.add(crateAvatarDrawable(id, drawable));
        layoutDrawables();
    }

    drawable.setCallback(this);
    drawable.setVisible(getWindowVisibility() == VISIBLE && isShown(), true);
    if (drawable.isStateful()) {
        drawable.setState(getDrawableState());
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        drawable.setLayoutDirection(getLayoutDirection());
    }
    invalidate();

    return true;
}
 
開發者ID:YiiGuxing,項目名稱:CompositionAvatar,代碼行數:38,代碼來源:CompositionAvatarView.java

示例15: setViewDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void setViewDrawable(ImageView v, Drawable drawable, int nullVisibility) {
    v.setImageDrawable(drawable);
    if (drawable == null) {
        v.setVisibility(nullVisibility);
        return;
    }
    v.setVisibility(0);
    drawable.setVisible(false, false);
    drawable.setVisible(true, false);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:SuggestionsAdapter.java


注:本文中的android.graphics.drawable.Drawable.setVisible方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。