List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:com.hb.hkm.slidinglayer.SlidLayer.java
private void adjustLayoutParams() { ViewGroup.LayoutParams baseParams = getLayoutParams(); if (baseParams instanceof LayoutParams) { LayoutParams layoutParams = (LayoutParams) baseParams; switch (mScreenSide) { case STICK_TO_BOTTOM: layoutParams.gravity = Gravity.BOTTOM; break; case STICK_TO_LEFT: layoutParams.gravity = Gravity.LEFT; break; case STICK_TO_RIGHT: layoutParams.gravity = Gravity.RIGHT; break; case STICK_TO_TOP: layoutParams.gravity = Gravity.TOP; break; }/*www . j av a2 s. c o m*/ setLayoutParams(baseParams); } else if (baseParams instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) baseParams; switch (mScreenSide) { case STICK_TO_BOTTOM: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); break; case STICK_TO_LEFT: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); break; case STICK_TO_RIGHT: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); break; case STICK_TO_TOP: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); break; } } }
From source file:android.support.v17.leanback.app.GuidedStepFragment.java
/** * Called by Constructor to provide fragment transitions. The default implementation assigns * transitions based on {@link #getUiStyle()}: * <ul>//from w ww. j a v a2s . com * <li> {@link #UI_STYLE_REPLACE} Slide from/to end(right) for enter transition, slide from/to * start(left) for exit transition, shared element enter transition is set to ChangeBounds. * <li> {@link #UI_STYLE_ENTRANCE} Enter transition is set to slide from both sides, exit * transition is same as {@link #UI_STYLE_REPLACE}, no shared element enter transition. * <li> {@link #UI_STYLE_ACTIVITY_ROOT} Enter transition is set to null and app should rely on * activity transition, exit transition is same as {@link #UI_STYLE_REPLACE}, no shared element * enter transition. * </ul> * <p> * The default implementation heavily relies on {@link GuidedActionsStylist} and * {@link GuidanceStylist} layout, app may override this method when modifying the default * layout of {@link GuidedActionsStylist} or {@link GuidanceStylist}. * <p> * TIP: because the fragment view is removed during fragment transition, in general app cannot * use two Visibility transition together. Workaround is to create your own Visibility * transition that controls multiple animators (e.g. slide and fade animation in one Transition * class). */ protected void onProvideFragmentTransitions() { if (Build.VERSION.SDK_INT >= 21) { final int uiStyle = getUiStyle(); if (uiStyle == UI_STYLE_REPLACE) { Object enterTransition = TransitionHelper.createFadeAndShortSlide(Gravity.END); TransitionHelper.exclude(enterTransition, R.id.guidedstep_background, true); TransitionHelper.setEnterTransition(this, enterTransition); Object changeBounds = TransitionHelper.createChangeBounds(false); TransitionHelper.setSharedElementEnterTransition(this, changeBounds); } else if (uiStyle == UI_STYLE_ENTRANCE) { if (entranceTransitionType == SLIDE_FROM_SIDE) { Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, R.id.guidedstep_background); Object slideFromSide = TransitionHelper.createFadeAndShortSlide(Gravity.END | Gravity.START); TransitionHelper.include(slideFromSide, R.id.content_fragment); TransitionHelper.include(slideFromSide, R.id.action_fragment_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, fade); TransitionHelper.addTransition(enterTransition, slideFromSide); TransitionHelper.setEnterTransition(this, enterTransition); } else { Object slideFromBottom = TransitionHelper.createFadeAndShortSlide(Gravity.BOTTOM); TransitionHelper.include(slideFromBottom, R.id.guidedstep_background_view_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, slideFromBottom); TransitionHelper.setEnterTransition(this, enterTransition); } // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } else if (uiStyle == UI_STYLE_ACTIVITY_ROOT) { // for Activity root, we dont need enter transition, use activity transition TransitionHelper.setEnterTransition(this, null); // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } // exitTransition is same for all style Object exitTransition = TransitionHelper.createFadeAndShortSlide(Gravity.START); TransitionHelper.exclude(exitTransition, R.id.guidedstep_background, true); TransitionHelper.setExitTransition(this, exitTransition); } }
From source file:flex.android.magiccube.activity.ActivityBattleMode.java
public void LeaveOnError(String msg) { Toast toast = Toast.makeText(this, msg, Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, height / 11); toast.show();//from www . j a va2 s.c o m State = OnStateListener.LEAVING_ON_ERROR; finish(); }
From source file:ab.util.AbDialogUtil.java
/** * // w w w . j a v a 2 s . c o m */ public static MyPop showDatePopWindowDate(Context context, View contentView, View targetView) { // yearArrayString = getYEARArray(2016, 36); monthArrayString = getDayArray(12); hourArrayString = getHMArray(24); minuteArrayString = getHMArray(60); // ?? c = Calendar.getInstance(); PopupWindow popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); yearWV = (WheelView) contentView.findViewById(R.id.time_year); monthWV = (WheelView) contentView.findViewById(R.id.time_month); dayWV = (WheelView) contentView.findViewById(R.id.time_day); hourWV = (WheelView) contentView.findViewById(R.id.time_hour); minuteWV = (WheelView) contentView.findViewById(R.id.time_minute); hourWV.setVisibility(View.GONE); minuteWV.setVisibility(View.GONE); // ? yearWV.setVisibleItems(5); monthWV.setVisibleItems(5); dayWV.setVisibleItems(5); hourWV.setVisibleItems(5); minuteWV.setVisibleItems(5); // yearWV.setLabel(""); monthWV.setLabel(""); dayWV.setLabel(""); hourWV.setLabel(""); minuteWV.setLabel(""); yearWV.setCyclic(true); monthWV.setCyclic(true); dayWV.setCyclic(true); hourWV.setCyclic(true); minuteWV.setCyclic(true); setData(); return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV); }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
/** * Given the desired width and height of the ring and the allocated width and height, compute * how much we need to scale the ring./*from w w w . jav a2 s . c o m*/ */ private float computeScaleFactor(int desiredWidth, int desiredHeight, int actualWidth, int actualHeight) { // Return unity if scaling is not allowed. if (!mAllowScaling) return 1f; final int layoutDirection = getLayoutDirection(); final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection); float scaleX = 1f; float scaleY = 1f; // We use the gravity as a cue for whether we want to scale on a particular axis. // We only scale to fit horizontally if we're not pinned to the left or right. Likewise, // we only scale to fit vertically if we're not pinned to the top or bottom. In these // cases, we want the ring to hang off the side or top/bottom, respectively. switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.LEFT: case Gravity.RIGHT: break; case Gravity.CENTER_HORIZONTAL: default: if (desiredWidth > actualWidth) { scaleX = (1f * actualWidth - mMaxTargetWidth) / (desiredWidth - mMaxTargetWidth); } break; } switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: case Gravity.BOTTOM: break; case Gravity.CENTER_VERTICAL: default: if (desiredHeight > actualHeight) { scaleY = (1f * actualHeight - mMaxTargetHeight) / (desiredHeight - mMaxTargetHeight); } break; } return Math.min(scaleX, scaleY); }
From source file:com.rbware.github.androidcouchpotato.app.GuidedStepFragment.java
/** * Called by Constructor to provide fragment transitions. The default implementation assigns * transitions based on {@link #getUiStyle()}: * <ul>/*from w ww .j a v a 2 s. co m*/ * <li> {@link #UI_STYLE_REPLACE} Slide from/to end(right) for enter transition, slide from/to * start(left) for exit transition, shared element enter transition is set to ChangeBounds. * <li> {@link #UI_STYLE_ENTRANCE} Enter transition is set to slide from both sides, exit * transition is same as {@link #UI_STYLE_REPLACE}, no shared element enter transition. * <li> {@link #UI_STYLE_ACTIVITY_ROOT} Enter transition is set to null and app should rely on * activity transition, exit transition is same as {@link #UI_STYLE_REPLACE}, no shared element * enter transition. * </ul> * <p> * The default implementation heavily relies on {@link GuidedActionsStylist} and * {@link GuidanceStylist} layout, app may override this method when modifying the default * layout of {@link GuidedActionsStylist} or {@link GuidanceStylist}. * <p> * TIP: because the fragment view is removed during fragment transition, in general app cannot * use two Visibility transition together. Workaround is to create your own Visibility * transition that controls multiple animators (e.g. slide and fade animation in one Transition * class). */ protected void onProvideFragmentTransitions() { if (Build.VERSION.SDK_INT >= 21) { final int uiStyle = getUiStyle(); if (uiStyle == UI_STYLE_REPLACE) { Object enterTransition = TransitionHelper.createFadeAndShortSlide(Gravity.END); TransitionHelper.exclude(enterTransition, R.id.guidedstep_background, true); TransitionHelper.exclude(enterTransition, R.id.guidedactions_sub_list_background, true); TransitionHelper.setEnterTransition(this, enterTransition); Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, R.id.guidedactions_sub_list_background); Object changeBounds = TransitionHelper.createChangeBounds(false); Object sharedElementTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(sharedElementTransition, fade); TransitionHelper.addTransition(sharedElementTransition, changeBounds); TransitionHelper.setSharedElementEnterTransition(this, sharedElementTransition); } else if (uiStyle == UI_STYLE_ENTRANCE) { if (entranceTransitionType == SLIDE_FROM_SIDE) { Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, R.id.guidedstep_background); Object slideFromSide = TransitionHelper.createFadeAndShortSlide(Gravity.END | Gravity.START); TransitionHelper.include(slideFromSide, R.id.content_fragment); TransitionHelper.include(slideFromSide, R.id.action_fragment_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, fade); TransitionHelper.addTransition(enterTransition, slideFromSide); TransitionHelper.setEnterTransition(this, enterTransition); } else { Object slideFromBottom = TransitionHelper.createFadeAndShortSlide(Gravity.BOTTOM); TransitionHelper.include(slideFromBottom, R.id.guidedstep_background_view_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, slideFromBottom); TransitionHelper.setEnterTransition(this, enterTransition); } // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } else if (uiStyle == UI_STYLE_ACTIVITY_ROOT) { // for Activity root, we don't need enter transition, use activity transition TransitionHelper.setEnterTransition(this, null); // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } // exitTransition is same for all style Object exitTransition = TransitionHelper.createFadeAndShortSlide(Gravity.START); TransitionHelper.exclude(exitTransition, R.id.guidedstep_background, true); TransitionHelper.exclude(exitTransition, R.id.guidedactions_sub_list_background, true); TransitionHelper.setExitTransition(this, exitTransition); } }
From source file:administrator.example.com.myscrollview.VerticalViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // For simple implementation, or internal size is always 0. // We depend on the container to specify the layout size of // our view. We can't really know what it is since we will be // adding and removing different arbitrary views and do not // want the layout to change as this happens. setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec)); // Children are just made to fill our space. int childWidthSize = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); int childHeightSize = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); /*//from ww w. j a v a 2s. com * Make sure all children have been properly measured. Decor views first. * Right now we cheat and make this less complicated by assuming decor * views won't intersect. We will pin to edges based on gravity. */ int size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp != null && lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; Log.d(TAG, "gravity: " + lp.gravity + " hgrav: " + hgrav + " vgrav: " + vgrav); int widthMode = MeasureSpec.AT_MOST; int heightMode = MeasureSpec.AT_MOST; boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM; boolean consumeHorizontal = hgrav == Gravity.LEFT || hgrav == Gravity.RIGHT; if (consumeVertical) { widthMode = MeasureSpec.EXACTLY; } else if (consumeHorizontal) { heightMode = MeasureSpec.EXACTLY; } /* end of if */ final int widthSpec = MeasureSpec.makeMeasureSpec(childWidthSize, widthMode); final int heightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, heightMode); child.measure(widthSpec, heightSpec); if (consumeVertical) { childHeightSize -= child.getMeasuredHeight(); } else if (consumeHorizontal) { childWidthSize -= child.getMeasuredWidth(); } /* end of if */ } /* end of if */ } /* end of if */ } /* end of for */ mChildWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY); mChildHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY); // Make sure we have created all fragments that we need to have shown. mInLayout = true; populate(); mInLayout = false; // Page views next. size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { if (DEBUG) Log.v(TAG, "Measuring #" + i + " " + child + ": " + mChildWidthMeasureSpec); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp == null || !lp.isDecor) { child.measure(mChildWidthMeasureSpec, mChildHeightMeasureSpec); } /* end of if */ } /* end of if */ } /* end of for */ }
From source file:com.panahit.ui.Components.EmojiView.java
public EmojiView(boolean needStickers, boolean needGif, final Context context) { super(context); showStickers = needStickers;/* www .jav a 2 s.c o m*/ showGifs = needGif; for (int i = 0; i < EmojiData.dataColored.length + 1; i++) { GridView gridView = new GridView(context); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else { gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(i - 1); gridView.setAdapter(emojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); adapters.add(emojiGridAdapter); } if (showStickers) { StickersQuery.checkStickers(); stickersGridView = new GridView(context) { @Override public boolean onInterceptTouchEvent(MotionEvent event) { boolean result = StickerPreviewViewer.getInstance().onInterceptTouchEvent(event, stickersGridView, EmojiView.this.getMeasuredHeight()); return super.onInterceptTouchEvent(event) || result; } @Override public void setVisibility(int visibility) { if (gifsGridView != null && gifsGridView.getVisibility() == VISIBLE) { super.setVisibility(GONE); return; } super.setVisibility(visibility); } }; stickersGridView.setSelector(R.drawable.transparent); stickersGridView.setColumnWidth(AndroidUtilities.dp(72)); stickersGridView.setNumColumns(-1); stickersGridView.setPadding(0, AndroidUtilities.dp(4), 0, 0); stickersGridView.setClipToPadding(false); views.add(stickersGridView); stickersGridAdapter = new StickersGridAdapter(context); stickersGridView.setAdapter(stickersGridAdapter); stickersGridView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return StickerPreviewViewer.getInstance().onTouch(event, stickersGridView, EmojiView.this.getMeasuredHeight(), stickersOnItemClickListener); } }); stickersOnItemClickListener = new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long i) { if (!(view instanceof StickerEmojiCell)) { return; } StickerPreviewViewer.getInstance().reset(); StickerEmojiCell cell = (StickerEmojiCell) view; if (cell.isDisabled()) { return; } cell.disable(); TLRPC.Document document = cell.getSticker(); int index = newRecentStickers.indexOf(document.id); if (index == -1) { newRecentStickers.add(0, document.id); if (newRecentStickers.size() > 20) { newRecentStickers.remove(newRecentStickers.size() - 1); } } else if (index != 0) { newRecentStickers.remove(index); newRecentStickers.add(0, document.id); } saveRecentStickers(); if (listener != null) { listener.onStickerSelected(document); } } }; stickersGridView.setOnItemClickListener(stickersOnItemClickListener); AndroidUtilities.setListViewEdgeEffectColor(stickersGridView, 0xfff5f6f7); stickersWrap = new FrameLayout(context); stickersWrap.addView(stickersGridView); if (needGif) { gifsGridView = new RecyclerListView(context); gifsGridView.setLayoutManager(flowLayoutManager = new FlowLayoutManager() { private Size size = new Size(); @Override protected Size getSizeForItem(int i) { TLRPC.Document document = recentImages.get(i).document; size.width = document.thumb != null && document.thumb.w != 0 ? document.thumb.w : 100; size.height = document.thumb != null && document.thumb.h != 0 ? document.thumb.h : 100; for (int b = 0; b < document.attributes.size(); b++) { TLRPC.DocumentAttribute attribute = document.attributes.get(b); if (attribute instanceof TLRPC.TL_documentAttributeImageSize || attribute instanceof TLRPC.TL_documentAttributeVideo) { size.width = attribute.w; size.height = attribute.h; break; } } return size; } }); if (Build.VERSION.SDK_INT >= 9) { gifsGridView.setOverScrollMode(RecyclerListView.OVER_SCROLL_NEVER); } gifsGridView.setAdapter(gifsAdapter = new GifsAdapter(context)); gifsGridView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (position < 0 || position >= recentImages.size() || listener == null) { return; } TLRPC.Document document = recentImages.get(position).document; listener.onStickerSelected(document); } }); gifsGridView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() { @Override public boolean onItemClick(View view, int position) { if (position < 0 || position >= recentImages.size()) { return false; } final MediaController.SearchImage searchImage = recentImages.get(position); AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("DeleteGif", R.string.DeleteGif)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK).toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { recentImages.remove(searchImage); TLRPC.TL_messages_saveGif req = new TLRPC.TL_messages_saveGif(); req.id = new TLRPC.TL_inputDocument(); req.id.id = searchImage.document.id; req.id.access_hash = searchImage.document.access_hash; req.unsave = true; ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { } }); MessagesStorage.getInstance().removeWebRecent(searchImage); if (gifsAdapter != null) { gifsAdapter.notifyDataSetChanged(); } if (recentImages.isEmpty()) { updateStickerTabs(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.show().setCanceledOnTouchOutside(true); return true; } }); gifsGridView.setVisibility(GONE); stickersWrap.addView(gifsGridView); } stickersEmptyView = new TextView(context); stickersEmptyView.setText(LocaleController.getString("NoStickers", R.string.NoStickers)); stickersEmptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); stickersEmptyView.setTextColor(0xff888888); stickersWrap.addView(stickersEmptyView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); stickersGridView.setEmptyView(stickersEmptyView); scrollSlidingTabStrip = new ScrollSlidingTabStrip(context) { boolean startedScroll; float lastX; float lastTranslateX; boolean first = true; @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { if (Build.VERSION.SDK_INT >= 11) { if (first) { first = false; lastX = ev.getX(); } float newTranslationX = ViewProxy.getTranslationX(scrollSlidingTabStrip); if (scrollSlidingTabStrip.getScrollX() == 0 && newTranslationX == 0) { if (!startedScroll && lastX - ev.getX() < 0) { if (pager.beginFakeDrag()) { startedScroll = true; lastTranslateX = ViewProxy.getTranslationX(scrollSlidingTabStrip); } } else if (startedScroll && lastX - ev.getX() > 0) { if (pager.isFakeDragging()) { pager.endFakeDrag(); startedScroll = false; } } } if (startedScroll) { int dx = (int) (ev.getX() - lastX + newTranslationX - lastTranslateX); try { pager.fakeDragBy(dx); lastTranslateX = newTranslationX; } catch (Exception e) { try { pager.endFakeDrag(); } catch (Exception e2) { //don't promt } startedScroll = false; FileLog.e("tmessages", e); } } lastX = ev.getX(); if (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP) { first = true; if (startedScroll) { pager.endFakeDrag(); startedScroll = false; } } return startedScroll || super.onTouchEvent(ev); } return super.onTouchEvent(ev); } }; scrollSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1)); scrollSlidingTabStrip.setIndicatorColor(0xffe2e5e7); scrollSlidingTabStrip.setUnderlineColor(0xffe2e5e7); scrollSlidingTabStrip.setVisibility(INVISIBLE); addView(scrollSlidingTabStrip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP)); ViewProxy.setTranslationX(scrollSlidingTabStrip, AndroidUtilities.displaySize.x); updateStickerTabs(); scrollSlidingTabStrip.setDelegate(new ScrollSlidingTabStrip.ScrollSlidingTabStripDelegate() { @Override public void onPageSelected(int page) { if (gifsGridView != null) { if (page == gifTabBum + 1) { if (gifsGridView.getVisibility() != VISIBLE) { listener.onGifTab(true); showGifTab(); } } else { if (gifsGridView.getVisibility() == VISIBLE) { listener.onGifTab(false); gifsGridView.setVisibility(GONE); stickersGridView.setVisibility(VISIBLE); stickersEmptyView .setVisibility(stickersGridAdapter.getCount() != 0 ? GONE : VISIBLE); } } } if (page == 0) { pager.setCurrentItem(0); return; } else { if (page == gifTabBum + 1) { return; } else { if (page == recentTabBum + 1) { views.get(6).setSelection(0); return; } } } int index = page - 1 - stickersTabOffset; if (index == stickerSets.size()) { if (listener != null) { listener.onStickersSettingsClick(); } return; } if (index >= stickerSets.size()) { index = stickerSets.size() - 1; } views.get(6).setSelection(stickersGridAdapter.getPositionForPack(stickerSets.get(index))); } }); stickersGridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { checkStickersScroll(firstVisibleItem); } }); } setBackgroundColor(0xfff5f6f7); pager = new ViewPager(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } }; pager.setAdapter(new EmojiPagesAdapter()); pagerSlidingTabStripContainer = new LinearLayout(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } }; pagerSlidingTabStripContainer.setOrientation(LinearLayout.HORIZONTAL); pagerSlidingTabStripContainer.setBackgroundColor(0xfff5f6f7); addView(pagerSlidingTabStripContainer, LayoutHelper.createFrame(LayoutParams.MATCH_PARENT, 48)); PagerSlidingTabStrip pagerSlidingTabStrip = new PagerSlidingTabStrip(context); pagerSlidingTabStrip.setViewPager(pager); pagerSlidingTabStrip.setShouldExpand(true); pagerSlidingTabStrip.setIndicatorHeight(AndroidUtilities.dp(2)); pagerSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1)); pagerSlidingTabStrip.setIndicatorColor(0xff2b96e2); pagerSlidingTabStrip.setUnderlineColor(0xffe2e5e7); pagerSlidingTabStripContainer.addView(pagerSlidingTabStrip, LayoutHelper.createLinear(0, 48, 1.0f)); pagerSlidingTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { EmojiView.this.onPageScrolled(position, getMeasuredWidth(), positionOffsetPixels); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); FrameLayout frameLayout = new FrameLayout(context); pagerSlidingTabStripContainer.addView(frameLayout, LayoutHelper.createLinear(52, 48)); backspaceButton = new ImageView(context) { @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { backspacePressed = true; backspaceOnce = false; postBackspaceRunnable(350); } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { backspacePressed = false; if (!backspaceOnce) { if (listener != null && listener.onBackspace()) { backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } } super.onTouchEvent(event); return true; } }; backspaceButton.setImageResource(R.drawable.ic_smiles_backspace); backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace); backspaceButton.setScaleType(ImageView.ScaleType.CENTER); frameLayout.addView(backspaceButton, LayoutHelper.createFrame(52, 48)); View view = new View(context); view.setBackgroundColor(0xffe2e5e7); frameLayout.addView(view, LayoutHelper.createFrame(52, 1, Gravity.LEFT | Gravity.BOTTOM)); recentsWrap = new FrameLayout(context); recentsWrap.addView(views.get(0)); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); textView.setTextSize(18); textView.setTextColor(0xff888888); textView.setGravity(Gravity.CENTER); recentsWrap.addView(textView); views.get(0).setEmptyView(textView); addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 48, 0, 0)); emojiSize = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 40 : 32); pickerView = new EmojiColorPickerView(context); pickerViewPopup = new EmojiPopupWindow(pickerView, popupWidth = AndroidUtilities.dp((AndroidUtilities.isTablet() ? 40 : 32) * 6 + 10 + 4 * 5), popupHeight = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 64 : 56)); pickerViewPopup.setOutsideTouchable(true); pickerViewPopup.setClippingEnabled(true); pickerViewPopup.setInputMethodMode(EmojiPopupWindow.INPUT_METHOD_NOT_NEEDED); pickerViewPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED); pickerViewPopup.getContentView().setFocusableInTouchMode(true); pickerViewPopup.getContentView().setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_UP && pickerViewPopup != null && pickerViewPopup.isShowing()) { pickerViewPopup.dismiss(); return true; } return false; } }); loadRecents(); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java
public boolean setValueFromTheme(TypedArray remoteTypedArray, final int[] padding, final int localAttrId, final int remoteTypedArrayIndex) { try {//from w w w. ja va 2 s .c om if (localAttrId == android.R.attr.background) { Drawable keyboardBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); Log.d(TAG, "AnySoftKeyboardTheme_android_background " + (keyboardBackground != null)); super.setBackgroundDrawable(keyboardBackground); } else if (localAttrId == android.R.attr.paddingLeft) { padding[0] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_android_paddingLeft " + padding[0]); } else if (localAttrId == android.R.attr.paddingTop) { padding[1] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_android_paddingTop " + padding[1]); } else if (localAttrId == android.R.attr.paddingRight) { padding[2] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_android_paddingRight " + padding[2]); } else if (localAttrId == android.R.attr.paddingBottom) { padding[3] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_android_paddingBottom " + padding[3]); } else if (localAttrId == R.attr.keyBackground) { mKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); Log.d(TAG, "AnySoftKeyboardTheme_keyBackground " + (mKeyBackground != null)); } else if (localAttrId == R.attr.keyHysteresisDistance) { mKeyHysteresisDistance = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_keyHysteresisDistance " + mKeyHysteresisDistance); } else if (localAttrId == R.attr.verticalCorrection) { mVerticalCorrection = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_verticalCorrection " + mVerticalCorrection); } else if (localAttrId == R.attr.keyPreviewBackground) { mPreviewKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewBackground " + (mPreviewKeyBackground != null)); } else if (localAttrId == R.attr.keyPreviewTextColor) { mPreviewKeyTextColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFF); Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewTextColor " + mPreviewKeyTextColor); } else if (localAttrId == R.attr.keyPreviewTextSize) { mPreviewKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewTextSize " + mPreviewKeyTextSize); } else if (localAttrId == R.attr.keyPreviewLabelTextSize) { mPreviewLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewLabelTextSize " + mPreviewLabelTextSize); } else if (localAttrId == R.attr.keyPreviewOffset) { mPreviewOffset = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_keyPreviewOffset " + mPreviewOffset); } else if (localAttrId == R.attr.keyTextSize) { mKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 18); // you might ask yourself "why did Menny sqrt root the factor?" // I'll tell you; the factor is mostly for the height, not the // font size, // but I also factorize the font size because I want the text to // be a little like // the key size. // the whole factor maybe too much, so I ease that a bit. if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyTextSize = mKeyTextSize * FloatMath.sqrt(AnyApplication.getConfig().getKeysHeightFactorInLandscape()); else mKeyTextSize = mKeyTextSize * FloatMath.sqrt(AnyApplication.getConfig().getKeysHeightFactorInPortrait()); Log.d(TAG, "AnySoftKeyboardTheme_keyTextSize " + mKeyTextSize); } else if (localAttrId == R.attr.keyTextColor) { mKeyTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mKeyTextColor == null) { Log.d(TAG, "Creating an empty ColorStateList for mKeyTextColor"); mKeyTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) }); } Log.d(TAG, "AnySoftKeyboardTheme_keyTextColor " + mKeyTextColor); } else if (localAttrId == R.attr.labelTextSize) { mLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 14); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); Log.d(TAG, "AnySoftKeyboardTheme_labelTextSize " + mLabelTextSize); } else if (localAttrId == R.attr.keyboardNameTextSize) { mKeyboardNameTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 10); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyboardNameTextSize = mKeyboardNameTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mKeyboardNameTextSize = mKeyboardNameTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); Log.d(TAG, "AnySoftKeyboardTheme_keyboardNameTextSize " + mKeyboardNameTextSize); } else if (localAttrId == R.attr.keyboardNameTextColor) { mKeyboardNameTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mKeyboardNameTextColor == null) { Log.d(TAG, "Creating an empty ColorStateList for mKeyboardNameTextColor"); mKeyboardNameTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFAAAAAA) }); } Log.d(TAG, "AnySoftKeyboardTheme_keyboardNameTextColor " + mKeyboardNameTextColor); } else if (localAttrId == R.attr.shadowColor) { mShadowColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_shadowColor " + mShadowColor); } else if (localAttrId == R.attr.shadowRadius) { mShadowRadius = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_shadowRadius " + mShadowRadius); } else if (localAttrId == R.attr.shadowOffsetX) { mShadowOffsetX = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_shadowOffsetX " + mShadowOffsetX); } else if (localAttrId == R.attr.shadowOffsetY) { mShadowOffsetY = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_shadowOffsetY " + mShadowOffsetY); } else if (localAttrId == R.attr.backgroundDimAmount) { mBackgroundDimAmount = remoteTypedArray.getFloat(remoteTypedArrayIndex, 0.5f); Log.d(TAG, "AnySoftKeyboardTheme_backgroundDimAmount " + mBackgroundDimAmount); } else if (localAttrId == R.attr.keyTextStyle) { int textStyle = remoteTypedArray.getInt(remoteTypedArrayIndex, 0); switch (textStyle) { case 0: mKeyTextStyle = Typeface.DEFAULT; break; case 1: mKeyTextStyle = Typeface.DEFAULT_BOLD; break; case 2: mKeyTextStyle = Typeface.defaultFromStyle(Typeface.ITALIC); break; default: mKeyTextStyle = Typeface.defaultFromStyle(textStyle); break; } Log.d(TAG, "AnySoftKeyboardTheme_keyTextStyle " + mKeyTextStyle); } else if (localAttrId == R.attr.symbolColorScheme) { mSymbolColorScheme = remoteTypedArray.getInt(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_symbolColorScheme " + mSymbolColorScheme); } else if (localAttrId == R.attr.keyHorizontalGap) { float themeHorizotalKeyGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); mKeyboardDimens.setHorizontalKeyGap(themeHorizotalKeyGap); Log.d(TAG, "AnySoftKeyboardTheme_keyHorizontalGap " + themeHorizotalKeyGap); } else if (localAttrId == R.attr.keyVerticalGap) { float themeVerticalRowGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); mKeyboardDimens.setVerticalRowGap(themeVerticalRowGap); Log.d(TAG, "AnySoftKeyboardTheme_keyVerticalGap " + themeVerticalRowGap); } else if (localAttrId == R.attr.keyNormalHeight) { float themeNormalKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); mKeyboardDimens.setNormalKeyHeight(themeNormalKeyHeight); Log.d(TAG, "AnySoftKeyboardTheme_keyNormalHeight " + themeNormalKeyHeight); } else if (localAttrId == R.attr.keyLargeHeight) { float themeLargeKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); mKeyboardDimens.setLargeKeyHeight(themeLargeKeyHeight); Log.d(TAG, "AnySoftKeyboardTheme_keyLargeHeight " + themeLargeKeyHeight); } else if (localAttrId == R.attr.keySmallHeight) { float themeSmallKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); mKeyboardDimens.setSmallKeyHeight(themeSmallKeyHeight); Log.d(TAG, "AnySoftKeyboardTheme_keySmallHeight " + themeSmallKeyHeight); } else if (localAttrId == R.attr.hintTextSize) { mHintTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_hintTextSize " + mHintTextSize); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); Log.d(TAG, "AnySoftKeyboardTheme_hintTextSize with factor " + mHintTextSize); } else if (localAttrId == R.attr.hintTextColor) { mHintTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mHintTextColor == null) { Log.d(TAG, "Creating an empty ColorStateList for mHintTextColor"); mHintTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) }); } Log.d(TAG, "AnySoftKeyboardTheme_hintTextColor " + mHintTextColor); } else if (localAttrId == R.attr.hintLabelVAlign) { mHintLabelVAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.BOTTOM); Log.d(TAG, "AnySoftKeyboardTheme_hintLabelVAlign " + mHintLabelVAlign); } else if (localAttrId == R.attr.hintLabelAlign) { mHintLabelAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.RIGHT); Log.d(TAG, "AnySoftKeyboardTheme_hintLabelAlign " + mHintLabelAlign); } else if (localAttrId == R.attr.hintOverflowLabel) { mHintOverflowLabel = remoteTypedArray.getString(remoteTypedArrayIndex); Log.d(TAG, "AnySoftKeyboardTheme_hintOverflowLabel " + mHintOverflowLabel); } return true; } catch (Exception e) { // on API changes, so the incompatible themes wont crash me.. e.printStackTrace(); return false; } }
From source file:com.chenglong.muscle.ui.LazyViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;//w w w . ja va2s . c om populate(); mInLayout = false; final int count = getChildCount(); int width = r - l; int height = b - t; int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); final int scrollX = getScrollX(); int decorCount = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); ItemInfo ii; int childLeft = 0; int childTop = 0; if (lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (hgrav) { default: childLeft = paddingLeft; break; case Gravity.LEFT: childLeft = paddingLeft; paddingLeft += child.getMeasuredWidth(); break; case Gravity.CENTER_HORIZONTAL: childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft); break; case Gravity.RIGHT: childLeft = width - paddingRight - child.getMeasuredWidth(); paddingRight += child.getMeasuredWidth(); break; } switch (vgrav) { default: childTop = paddingTop; break; case Gravity.TOP: childTop = paddingTop; paddingTop += child.getMeasuredHeight(); break; case Gravity.CENTER_VERTICAL: childTop = Math.max((height - child.getMeasuredHeight()) / 2, paddingTop); break; case Gravity.BOTTOM: childTop = height - paddingBottom - child.getMeasuredHeight(); paddingBottom += child.getMeasuredHeight(); break; } childLeft += scrollX; decorCount++; child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } else if ((ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * ii.position; childLeft = paddingLeft + loff; childTop = paddingTop; if (DEBUG) Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } } mTopPageBounds = paddingTop; mBottomPageBounds = height - paddingBottom; mDecorChildCount = decorCount; mFirstLayout = false; }