本文整理汇总了Java中android.view.View.getVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java View.getVisibility方法的具体用法?Java View.getVisibility怎么用?Java View.getVisibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getVisibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addView
import android.view.View; //导入方法依赖的package包/类
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (!checkLayoutParams(params)) {
params = generateLayoutParams(params);
}
final LayoutParams lp = (LayoutParams) params;
lp.isDecor |= child instanceof Decor;
if (mInLayout) {
if (lp != null && lp.isDecor) {
throw new IllegalStateException("Cannot add pager decor view during layout");
}
lp.needsMeasure = true;
addViewInLayout(child, index, params);
} else {
super.addView(child, index, params);
}
if (USE_CACHE) {
if (child.getVisibility() != GONE) {
child.setDrawingCacheEnabled(mScrollingCacheEnabled);
} else {
child.setDrawingCacheEnabled(false);
}
}
}
示例2: showContextMenu
import android.view.View; //导入方法依赖的package包/类
/**
* Starts showing a context menu for {@code view} based on {@code params}.
* @param contentViewCore The {@link ContentViewCore} to show the menu to.
* @param params The {@link ContextMenuParams} that indicate what menu items to show.
*/
@CalledByNative
private void showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) {
final View view = contentViewCore.getContainerView();
if (view == null
|| view.getVisibility() != View.VISIBLE
|| view.getParent() == null) {
return;
}
mCurrentContextMenuParams = params;
view.setOnCreateContextMenuListener(this);
if (view.showContextMenu()) {
WebContents webContents = contentViewCore.getWebContents();
RecordHistogram.recordBooleanHistogram(
"ContextMenu.Shown", webContents != null);
}
}
示例3: getAllChildrenHeightSum
import android.view.View; //导入方法依赖的package包/类
private int getAllChildrenHeightSum(boolean withPadding, boolean withMargin) {
final int childCount = getChildCount();
int height = 0;
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child.getVisibility() == GONE)
continue;
int margin = ((MarginLayoutParams) child.getLayoutParams()).topMargin +
((MarginLayoutParams) child.getLayoutParams()).bottomMargin;
height += child.getMeasuredHeight() +
(withPadding ? child.getPaddingTop() + child.getPaddingBottom() : 0) +
(withMargin ? margin : 0);
}
return Math.max(height, 0);
}
示例4: onLayout
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
inLayout = true;
int width = r - l;
int height = b - t;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
int x = (width - child.getMeasuredWidth()) / 2;
int y;
if (showAtCenter) {
y = (height / 2 - child.getMeasuredHeight()) / 2;
} else {
y = (height - child.getMeasuredHeight()) / 2;
}
child.layout(x, y, x + child.getMeasuredWidth(), y + child.getMeasuredHeight());
}
inLayout = false;
}
示例5: setScrollingCacheEnabled
import android.view.View; //导入方法依赖的package包/类
private void setScrollingCacheEnabled(boolean enabled)
{
if (mScrollingCacheEnabled != enabled)
{
mScrollingCacheEnabled = enabled;
if (USE_CACHE)
{
final int size = getChildCount();
for (int i = 0; i < size; ++i)
{
final View child = getChildAt(i);
if (child.getVisibility() != GONE)
{
child.setDrawingCacheEnabled(enabled);
}
}
}
}
}
示例6: onLayout
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getVisibility() != View.GONE) {
child.layout(0, 0, r - l, b - t);
}
}
}
示例7: onTouchEvent
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (mLastY == -1) {
mLastY = ev.getRawY();
}
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mLastY = ev.getRawY();
break;
case MotionEvent.ACTION_MOVE:
final float deltaY = ev.getRawY() - mLastY;
mLastY = ev.getRawY();
if (isOnTop() && pullRefreshEnabled) {
mRefreshHeader.onMove(deltaY / DRAG_RATE);
if (mRefreshHeader.getVisiableHeight() > 0 && mRefreshHeader.getState() < YunRefreshHeader.STATE_REFRESHING) {
return false;
}
}
break;
default:
mLastY = -1; // reset
if (isOnTop() && pullRefreshEnabled) {
if (mRefreshHeader.releaseAction()) {
if (mLoadingListener != null) {
mLoadingListener.onRefresh();
isnomore = false;
previousTotal = 0;
final View footView = mFootViews.get(0);
if (footView instanceof LoadingMoreFooter) {
if (footView.getVisibility() != View.GONE) {
footView.setVisibility(View.GONE);
}
}
}
}
}
break;
}
return super.onTouchEvent(ev);
}
示例8: onLayout
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int top = getPaddingTop();//开始布局子view的 top距离
int left = getPaddingLeft();//开始布局子view的 left距离
int lineNum = mAllViews.size();//行数
List<View> lineView;
int lineHeight;
for (int i = 0; i < lineNum; i++) {
lineView = mAllViews.get(i);
lineHeight = mLineHeight.get(i);
for (int j = 0; j < lineView.size(); j++) {
View child = lineView.get(j);
if (child.getVisibility() == View.GONE) {
continue;
}
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) child.getLayoutParams();
int ld = left + params.leftMargin;
int td = top + params.topMargin;
int rd = ld + child.getMeasuredWidth();//不需要加上 params.rightMargin,
int bd = td + child.getMeasuredHeight();//不需要加上 params.bottomMargin, 因为在 onMeasure , 中已经加在了 lineHeight 中
child.layout(ld, td, rd, bd);
left += child.getMeasuredWidth() + params.leftMargin + params.rightMargin;//因为在 这里添加了;
}
left = getPaddingLeft();
top += lineHeight;
}
}
示例9: adjustLayout
import android.view.View; //导入方法依赖的package包/类
@Override
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
if (requireLayoutView()) {
View refer = null;
Rect tempRect = new Rect();
final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
for (int i = 0; i < helper.getChildCount(); i++) {
refer = helper.getChildAt(i);
int anchorPos = helper.getPosition(refer);
if (getRange().contains(anchorPos)) {
if (refer.getVisibility() == View.GONE) {
tempRect.setEmpty();
} else {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
refer.getLayoutParams();
if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
orientationHelper.getDecoratedStart(refer),
helper.getDecoratedRight(refer) + params.rightMargin,
orientationHelper.getDecoratedEnd(refer));
} else {
tempRect.union(orientationHelper.getDecoratedStart(refer),
helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
helper.getDecoratedBottom(refer) + params.bottomMargin);
}
}
}
}
if (!tempRect.isEmpty()) {
mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
} else {
mLayoutRegion.setEmpty();
}
if (mLayoutView != null) {
mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
}
}
}
示例10: expand
import android.view.View; //导入方法依赖的package包/类
public static Animation expand(final View v, int duration, boolean startAnim) {
if (v.getVisibility() == View.VISIBLE)
return null;
v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
v.getLayoutParams().height = 0;
v.setVisibility(View.VISIBLE);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1
? ViewGroup.LayoutParams.WRAP_CONTENT
: (int) (targetHeight * interpolatedTime);
v.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
};
a.setDuration(duration);
if (startAnim)
v.startAnimation(a);
return a;
}
示例11: addFocusables
import android.view.View; //导入方法依赖的package包/类
/**
* We only want the current page that is being shown to be focusable.
*/
@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
final int focusableCount = views.size();
final int descendantFocusability = getDescendantFocusability();
if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) {
for (int i = 0; i < getChildCount(); i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
ViewPager.ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem) {
child.addFocusables(views, direction, focusableMode);
}
}
}
}
// we add ourselves (if focusable) in all cases except for when we are
// FOCUS_AFTER_DESCENDANTS and there are some descendants focusable. this is
// to avoid the focus search finding layouts when a more precise search
// among the focusable children would be more interesting.
if (descendantFocusability != FOCUS_AFTER_DESCENDANTS
|| (focusableCount == views.size())) { // No focusable descendants
// Note that we can't call the superclass here, because it will
// add all views in. So we need to do the same thing View does.
if (!isFocusable()) {
return;
}
if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE
&& isInTouchMode() && !isFocusableInTouchMode()) {
return;
}
if (views != null) {
views.add(this);
}
}
}
示例12: onLayout
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int parentLeft = getPaddingLeft();
final int parentRight = r - l - getPaddingRight();
final int parentTop = getPaddingTop();
final int parentBottom = b - t - getPaddingBottom();
int childLeft = parentLeft;
int childTop = parentTop;
int rowMaxHeight = 0;
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
final int width = child.getMeasuredWidth();
final int height = child.getMeasuredHeight();
if (child.getVisibility() != GONE) {
if (childLeft + width > parentRight) { // Next line
childLeft = parentLeft;
childTop += rowMaxHeight + verticalSpacing;
rowMaxHeight = height;
} else {
rowMaxHeight = Math.max(rowMaxHeight, height);
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
childLeft += width + horizontalSpacing;
}
}
}
示例13: setScrollingCacheEnabled
import android.view.View; //导入方法依赖的package包/类
private void setScrollingCacheEnabled(boolean enabled) {
if (mScrollingCacheEnabled != enabled) {
mScrollingCacheEnabled = enabled;
if (USE_CACHE) {
final int size = getChildCount();
for (int i = 0; i < size; ++i) {
final View child = getChildAt(i);
if (child.getVisibility() != GONE) {
child.setDrawingCacheEnabled(enabled);
}
}
}
}
}
示例14: addTranslucentView
import android.view.View; //导入方法依赖的package包/类
/**
* 添加半透明矩形条
*
* @param activity 需要设置的 activity
* @param statusBarAlpha 透明值
*/
private static void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
View fakeTranslucentView = contentView.findViewWithTag(FAKE_TRANSLUCENT_VIEW_TAG);
if (fakeTranslucentView != null) {
if (fakeTranslucentView.getVisibility() == View.GONE) {
fakeTranslucentView.setVisibility(View.VISIBLE);
}
fakeTranslucentView.setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0));
} else {
contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}
}
示例15: onInitializeAccessibilityNodeInfo
import android.view.View; //导入方法依赖的package包/类
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
super.onInitializeAccessibilityNodeInfo(host, superNode);
copyNodeInfoNoChildren(info, superNode);
superNode.recycle();
info.setClassName(BGASwipeBackLayout2.class.getName());
info.setSource(host);
final ViewParent parent = ViewCompat.getParentForAccessibility(host);
if (parent instanceof View) {
info.setParent((View) parent);
}
// This is a best-approximation of addChildrenForAccessibility()
// that accounts for filtering.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
// Force importance to "yes" since we can't read the value.
ViewCompat.setImportantForAccessibility(
child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
info.addChild(child);
}
}
}