List of usage examples for android.view View setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java
public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity, HttpClient client, RedditSettings settings, ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) { Resources res = activity.getResources(); TextView titleView = (TextView) view.findViewById(R.id.title); TextView votesView = (TextView) view.findViewById(R.id.votes); TextView numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit); TextView nsfwView = (TextView) view.findViewById(R.id.nsfw); // TextView submissionTimeView = (TextView) view.findViewById(R.id.submissionTime); ImageView voteUpView = (ImageView) view.findViewById(R.id.vote_up_image); ImageView voteDownView = (ImageView) view.findViewById(R.id.vote_down_image); View thumbnailContainer = view.findViewById(R.id.thumbnail_view); FrameLayout thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame); ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail); ProgressBar indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress); // Set the title and domain using a SpannableStringBuilder SpannableStringBuilder builder = new SpannableStringBuilder(); String title = item.getTitle(); if (title == null) title = ""; SpannableString titleSS = new SpannableString(title); int titleLen = title.length(); titleSS.setSpan(//from w ww .j av a 2 s .c o m new TextAppearanceSpan(activity, Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)), 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); String domain = item.getDomain(); if (domain == null) domain = ""; int domainLen = domain.length(); SpannableString domainSS = new SpannableString("(" + item.getDomain() + ")"); domainSS.setSpan( new TextAppearanceSpan(activity, Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (Util.isLightTheme(settings.getTheme())) { if (item.isClicked()) { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { if (item.isClicked()) { ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50)); titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } builder.append(titleSS).append(" ").append(domainSS); titleView.setText(builder); votesView.setText("" + item.getScore()); numCommentsSubredditView.setText(Util.showNumComments(item.getNum_comments()) + " " + item.getSubreddit()); if (item.isOver_18()) { nsfwView.setVisibility(View.VISIBLE); } else { nsfwView.setVisibility(View.GONE); } // Set the up and down arrow colors based on whether user likes if (settings.isLoggedIn()) { if (item.getLikes() == null) { voteUpView.setImageResource(R.drawable.vote_up_gray); voteDownView.setImageResource(R.drawable.vote_down_gray); votesView.setTextColor(res.getColor(R.color.gray_75)); } else if (item.getLikes() == true) { voteUpView.setImageResource(R.drawable.vote_up_red); voteDownView.setImageResource(R.drawable.vote_down_gray); votesView.setTextColor(res.getColor(R.color.arrow_red)); } else { voteUpView.setImageResource(R.drawable.vote_up_gray); voteDownView.setImageResource(R.drawable.vote_down_blue); votesView.setTextColor(res.getColor(R.color.arrow_blue)); } } else { voteUpView.setImageResource(R.drawable.vote_up_gray); voteDownView.setImageResource(R.drawable.vote_down_gray); votesView.setTextColor(res.getColor(R.color.gray_75)); } // Thumbnails open links if (thumbnailContainer != null) { if (Common.shouldLoadThumbnails(activity, settings)) { thumbnailContainer.setVisibility(View.VISIBLE); if (item.getUrl() != null) { OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory .getThumbnailOnClickListener(item, activity); if (thumbnailOnClickListener != null) { thumbnailFrame.setOnClickListener(thumbnailOnClickListener); } } // Show thumbnail based on ThingInfo if ("default".equals(item.getThumbnail()) || "self".equals(item.getThumbnail()) || StringUtils.isEmpty(item.getThumbnail())) { indeterminateProgressBar.setVisibility(View.GONE); thumbnailImageView.setVisibility(View.VISIBLE); thumbnailImageView.setImageResource(R.drawable.go_arrow); } else { indeterminateProgressBar.setVisibility(View.GONE); thumbnailImageView.setVisibility(View.VISIBLE); if (item.getThumbnailBitmap() != null) { thumbnailImageView.setImageBitmap(item.getThumbnailBitmap()); } else { thumbnailImageView.setImageBitmap(null); new ShowThumbnailsTask(activity, client, R.drawable.go_arrow) .execute(new ThumbnailLoadAction(item, thumbnailImageView, position)); } } // Set thumbnail background based on current theme if (Util.isLightTheme(settings.getTheme())) thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light); else thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark); } else { // if thumbnails disabled, hide thumbnail icon thumbnailContainer.setVisibility(View.GONE); } } }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public Bitmap createWidgetBitmap(ItemInfoBean widgetInfo, View layout) { int[] unScaledSize = mLauncher.getWorkspace().estimateItemSize(widgetInfo.spanX, widgetInfo.spanY, widgetInfo, false);/* w w w . j a v a2s. c o m*/ int visibility = layout.getVisibility(); layout.setVisibility(VISIBLE); int width = MeasureSpec.makeMeasureSpec(unScaledSize[0], MeasureSpec.EXACTLY); int height = MeasureSpec.makeMeasureSpec(unScaledSize[1], MeasureSpec.EXACTLY); Bitmap b = Bitmap.createBitmap(unScaledSize[0], unScaledSize[1], Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); layout.measure(width, height); layout.layout(0, 0, unScaledSize[0], unScaledSize[1]); layout.draw(c); c.setBitmap(null); layout.setVisibility(visibility); return b; }
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;//from w ww . j ava 2 s. c om final int width = r - l; final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (isContentView(child)) { child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight()); } else { // Drawer, if it wasn't onMeasure would have thrown an exception. final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); int childLeft; final float newOffset; if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { childLeft = -childWidth + (int) (childWidth * lp.onScreen); newOffset = (float) (childWidth + childLeft) / childWidth; } else { // Right; onMeasure checked for us. childLeft = width - (int) (childWidth * lp.onScreen); newOffset = (float) (width - childLeft) / childWidth; } final boolean changeOffset = newOffset != lp.onScreen; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (vgrav) { default: case Gravity.TOP: { child.layout(childLeft, lp.topMargin, childLeft + childWidth, lp.topMargin + childHeight); break; } case Gravity.BOTTOM: { final int height = b - t; child.layout(childLeft, height - lp.bottomMargin - child.getMeasuredHeight(), childLeft + childWidth, height - lp.bottomMargin); break; } case Gravity.CENTER_VERTICAL: { final int height = b - t; int childTop = (height - childHeight) / 2; // Offset for margins. If things don't fit right because of // bad measurement before, oh well. if (childTop < lp.topMargin) { childTop = lp.topMargin; } else if (childTop + childHeight > height - lp.bottomMargin) { childTop = height - lp.bottomMargin - childHeight; } child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); break; } } if (changeOffset) { setDrawerViewOffset(child, newOffset); } final int newVisibility = lp.onScreen > 0 ? VISIBLE : INVISIBLE; if (child.getVisibility() != newVisibility) { child.setVisibility(newVisibility); } } } mInLayout = false; mFirstLayout = false; }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public void startDrag(CellLayout.CellInfo cellInfo) { View child = cellInfo.cell; // Make sure the drag was started by a long press as opposed to a long // click./*from ww w .j a va2 s. c om*/ if (!child.isInTouchMode()) { return; } mDragInfo = cellInfo; child.setVisibility(INVISIBLE); CellLayout layout = (CellLayout) child.getParent().getParent(); layout.prepareChildForDrag(child); child.clearFocus(); child.setPressed(false); final Canvas canvas = new Canvas(); // The outline is used to visualize where the item will land if dropped mDragOutline = createDragOutline(child, canvas, DRAG_BITMAP_PADDING); beginDragShared(child, this); }
From source file:self.philbrown.droidQuery.$.java
/** * Sets the visibility of the current selection to {@link View#VISIBLE} * @return this//from w ww . j a va 2s . c o m */ public $ hide() { for (View view : views) { view.setVisibility(View.VISIBLE); } return this; }
From source file:self.philbrown.droidQuery.$.java
/** * Sets the visibility of this {@link #view} to {@link View#INVISIBLE} * @return this//from w ww. j a va 2 s .c om */ public $ show() { for (View view : views) { view.setVisibility(View.INVISIBLE); } return this; }
From source file:ca.taglab.PictureFrame.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);/*from www . j a v a 2s .c o m*/ Bitmap picture = BitmapFactory.decodeFile(mImgPath); rootView.setBackground(new BitmapDrawable(getResources(), picture)); mConfirmation = (ImageView) rootView.findViewById(R.id.confirm); ((TextView) rootView.findViewById(R.id.name)).setText(mName); rootView.findViewById(R.id.control).getBackground().setAlpha(200); optionsOpen = false; mMsgHistory = rootView.findViewById(R.id.msg); mMsgHistory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MessagesActivity.class); intent.putExtra("user_name", mName); intent.putExtra("user_id", mId); intent.putExtra("owner_id", mOwnerId); startActivity(intent); hideOptions(); } }); mPhoto = rootView.findViewById(R.id.photo); mPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String filename = String.valueOf(System.currentTimeMillis()) + ".jpg"; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, filename); mCapturedImageURI = getActivity().getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); startActivityForResult(intent, CAPTURE_PICTURE); hideOptions(); } catch (Exception e) { Log.e(TAG, "Camera intent failed"); } } }); mVideo = rootView.findViewById(R.id.video); mVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String filename = String.valueOf(System.currentTimeMillis()) + ".3gp"; ContentValues values = new ContentValues(); values.put(MediaStore.Video.Media.TITLE, filename); mCapturedVideoURI = getActivity().getContentResolver() .insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedVideoURI); startActivityForResult(intent, CAPTURE_VIDEO); hideOptions(); } catch (Exception e) { Log.e(TAG, "Video intent failed"); } } }); mAudio = rootView.findViewById(R.id.audio); mAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent intent = new Intent(getActivity(), AudioRecorderActivity.class); startActivityForResult(intent, CAPTURE_AUDIO); hideOptions(); } catch (Exception e) { Log.e(TAG, "Audio intent failed"); } } }); mWave = rootView.findViewById(R.id.wave); mWave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I'm thinking of you", "Wave sent via PictureFrame", null).execute(); //Toast.makeText(getActivity(), "Wave sent to: " + mEmail, Toast.LENGTH_SHORT).show(); hideOptions(); messageSent(v); } catch (Exception e) { Log.e("SendEmailAsyncTask", e.getMessage(), e); //Toast.makeText(getActivity(), "Wave to " + mEmail + " failed", Toast.LENGTH_SHORT).show(); } } }); mCancel = rootView.findViewById(R.id.close); mPhoto.getBackground().setAlpha(200); mVideo.getBackground().setAlpha(200); mAudio.getBackground().setAlpha(200); mWave.getBackground().setAlpha(200); mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); mLongAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime); rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!optionsOpen) showOptions(); } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (optionsOpen) hideOptions(); } }); Cursor unread = getActivity().getContentResolver().query(UserContentProvider.MESSAGE_CONTENT_URI, MessageTable.PROJECTION, MessageTable.COL_TO_ID + "=? AND " + MessageTable.COL_FROM_ID + "=? AND " + MessageTable.COL_READ + "=?", new String[] { Long.toString(mOwnerId), Long.toString(mId), Long.toString(0) }, null); if (unread != null && unread.moveToFirst()) { rootView.findViewById(R.id.notification).setVisibility(View.VISIBLE); rootView.findViewById(R.id.notification).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MessagesActivity.class); intent.putExtra("user_name", mName); intent.putExtra("user_id", mId); intent.putExtra("owner_id", mOwnerId); startActivity(intent); v.setVisibility(View.INVISIBLE); } }); } if (unread != null) { unread.close(); } return rootView; }
From source file:cc.flydev.launcher.Workspace.java
public void animateWidgetDrop(ItemInfo info, CellLayout cellLayout, DragView dragView, final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) { Rect from = new Rect(); mLauncher.getDragLayer().getViewRectRelativeToSelf(dragView, from); int[] finalPos = new int[2]; float scaleXY[] = new float[2]; boolean scalePreview = !(info instanceof PendingAddShortcutInfo); getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, external, scalePreview);//from w ww.j a v a 2 s .co m Resources res = mLauncher.getResources(); int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200; // In the case where we've prebound the widget, we remove it from the DragLayer if (finalView instanceof AppWidgetHostView && external) { Log.d(TAG, "6557954 Animate widget drop, final view is appWidgetHostView"); mLauncher.getDragLayer().removeView(finalView); } if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) { Bitmap crossFadeBitmap = createWidgetBitmap(info, finalView); dragView.setCrossFadeBitmap(crossFadeBitmap); dragView.crossFade((int) (duration * 0.8f)); } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && external) { scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]); } DragLayer dragLayer = mLauncher.getDragLayer(); if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) { mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f, DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration); } else { int endStyle; if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) { endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE; } else { endStyle = DragLayer.ANIMATION_END_DISAPPEAR; ; } Runnable onComplete = new Runnable() { @Override public void run() { if (finalView != null) { finalView.setVisibility(VISIBLE); } if (onCompleteRunnable != null) { onCompleteRunnable.run(); } } }; dragLayer.animateViewIntoPosition(dragView, from.left, from.top, finalPos[0], finalPos[1], 1, 1, 1, scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this); } }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public void animateWidgetDrop(ItemInfoBean info, CellLayout cellLayout, DragView dragView, final Runnable onCompleteRunnable, int animationType, final View finalView, boolean external) { Rect from = new Rect(); mLauncher.getDragLayer().getViewRectRelativeToSelf(dragView, from); int[] finalPos = new int[2]; float scaleXY[] = new float[2]; boolean scalePreview = !(info instanceof PendingAddShortcutInfo); getFinalPositionForDropAnimation(finalPos, scaleXY, dragView, cellLayout, info, mTargetCell, external, scalePreview);//from w w w. j a va2 s. c om Resources res = mLauncher.getResources(); int duration = res.getInteger(R.integer.config_dropAnimMaxDuration) - 200; // In the case where we've prebound the widget, we remove it from the // DragLayer if (finalView instanceof AppWidgetHostView && external) { Log.d(TAG, "6557954 Animate widget drop, final view is appWidgetHostView"); mLauncher.getDragLayer().removeView(finalView); } if ((animationType == ANIMATE_INTO_POSITION_AND_RESIZE || external) && finalView != null) { Bitmap crossFadeBitmap = createWidgetBitmap(info, finalView); dragView.setCrossFadeBitmap(crossFadeBitmap); dragView.crossFade((int) (duration * 0.8f)); } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && external) { scaleXY[0] = scaleXY[1] = Math.min(scaleXY[0], scaleXY[1]); } DragLayer dragLayer = mLauncher.getDragLayer(); if (animationType == CANCEL_TWO_STAGE_WIDGET_DROP_ANIMATION) { mLauncher.getDragLayer().animateViewIntoPosition(dragView, finalPos, 0f, 0.1f, 0.1f, DragLayer.ANIMATION_END_DISAPPEAR, onCompleteRunnable, duration); } else { int endStyle; if (animationType == ANIMATE_INTO_POSITION_AND_REMAIN) { endStyle = DragLayer.ANIMATION_END_REMAIN_VISIBLE; } else { endStyle = DragLayer.ANIMATION_END_DISAPPEAR; ; } Runnable onComplete = new Runnable() { @Override public void run() { if (finalView != null) { finalView.setVisibility(VISIBLE); } if (onCompleteRunnable != null) { onCompleteRunnable.run(); } } }; dragLayer.animateViewIntoPosition(dragView, from.left, from.top, finalPos[0], finalPos[1], 1, 1, 1, scaleXY[0], scaleXY[1], onComplete, endStyle, duration, this); } }
From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java
/** * 12-03 22:59:19.686: I/BottomDrawerLayout(12480): onLayout() -- left = 0 * -- top = 0 -- right = 1080 -- b = 1675 12-03 22:59:19.686: * I/BottomDrawerLayout(12480): onLayout() -- childWidth = 750 -- * childHeight = 1675 -- lp.onScreen = 0.0 12-03 22:59:19.686: * I/BottomDrawerLayout(12480): onLayout() -- childLeft = -750 -- newOffset * = 0.0 12-03 22:59:19.686: I/BottomDrawerLayout(12480): onLayout() -- * childWidth = 750 -- childHeight = 1675 -- lp.onScreen = 0.0 12-03 * 22:59:19.686: I/BottomDrawerLayout(12480): onLayout() -- childLeft = 1080 * -- newOffset = 0.0//from ww w. j a va2 s . c om */ @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { Log.i(TAG, "onLayout() -- left = " + l + " -- top = " + t + " -- right = " + r + " -- b = " + b); mInLayout = true; final int width = r - l;// final int height = b - t;// final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (isContentView(child)) { child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight()); } else { // ?view final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); // Log.i(TAG, "onLayout() -- childWidth = " + childWidth + // " -- childHeight = " + childHeight // + " -- lp.onScreen = " + lp.onScreen); int childLeft = 0;// int childTop = 0;// float newOffset = 0;// switch (getDrawerViewAbsoluteGravity(child)) { case Gravity.LEFT: if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { // Log.i(TAG, "onLayout() -- 1"); childLeft = -childWidth + (int) (childWidth * lp.onScreen); newOffset = (float) (childWidth + childLeft) / childWidth;// ? } break; case Gravity.RIGHT: if (checkDrawerViewAbsoluteGravity(child, Gravity.RIGHT)) { // Log.i(TAG, "onLayout() -- 2"); childLeft = width - (int) (childWidth * lp.onScreen); newOffset = (float) (width - childLeft) / childWidth;// ? } break; case Gravity.TOP: if (checkDrawerViewAbsoluteGravity(child, Gravity.TOP)) { // Log.i(TAG, "onLayout() -- 3"); childTop = -childHeight + (int) (childHeight * lp.onScreen); newOffset = (float) (childHeight + childTop) / childHeight;// ? } break; case Gravity.BOTTOM: if (checkDrawerViewAbsoluteGravity(child, Gravity.BOTTOM)) { // Log.i(TAG, "onLayout() -- 4"); childTop = height - (int) (childHeight * lp.onScreen); newOffset = (float) (height - childTop) / childHeight;// ? } break; default: childTop = height - (int) (childHeight * lp.onScreen); newOffset = (float) (height - childTop) / childHeight;// ? break; } // ///////////////////////////////////////// // Log.i(TAG, "onLayout() -- childLeft = " + childLeft + // " -- newOffset = " + newOffset); final boolean changeOffset = newOffset != lp.onScreen; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (vgrav) { // case Gravity.TOP: { // Log.i(TAG, "onLayout() -- Gravity.TOP"); // child.layout(childLeft, lp.topMargin, childLeft + childWidth, // lp.topMargin + childHeight); // break; // } // case Gravity.BOTTOM: { // Log.i(TAG, "onLayout() -- Gravity.BOTTOM"); // child.layout(childLeft, height - lp.bottomMargin - // child.getMeasuredHeight(), childLeft // + childWidth, height - lp.bottomMargin); // break; // } case Gravity.CENTER_VERTICAL: { // Log.i(TAG, "onLayout() -- Gravity.CENTER_VERTICAL"); int childTop_cv = (height - childHeight) / 2; // Offset for margins. If things don't fit right because of // bad measurement before, oh well. if (childTop_cv < lp.topMargin) { childTop_cv = lp.topMargin; } else if (childTop_cv + childHeight > height - lp.bottomMargin) { childTop_cv = height - lp.bottomMargin - childHeight; } child.layout(childLeft, childTop_cv, childLeft + childWidth, childTop_cv + childHeight); break; } } // ///////////////////////////////////////// if (changeOffset) { setDrawerViewOffset(child, newOffset); } final int newVisibility = lp.onScreen > 0 ? VISIBLE : INVISIBLE; if (child.getVisibility() != newVisibility) { child.setVisibility(newVisibility); } } } mInLayout = false; mFirstLayout = false; }