List of usage examples for android.view Gravity TOP
int TOP
To view the source code for android.view Gravity TOP.
Click Source Link
From source file:android.support.v7.widget.LinearLayoutCompat.java
@Override public int getBaseline() { if (mBaselineAlignedChildIndex < 0) { return super.getBaseline(); }/*from ww w . j ava2s . c o m*/ if (getChildCount() <= mBaselineAlignedChildIndex) { throw new RuntimeException( "mBaselineAlignedChildIndex of LinearLayout " + "set to an index that is out of bounds."); } final View child = getChildAt(mBaselineAlignedChildIndex); final int childBaseline = child.getBaseline(); if (childBaseline == -1) { if (mBaselineAlignedChildIndex == 0) { // this is just the default case, safe to return -1 return -1; } // the user picked an index that points to something that doesn't // know how to calculate its baseline. throw new RuntimeException("mBaselineAlignedChildIndex of LinearLayout " + "points to a View that doesn't know how to get its baseline."); } // TODO: This should try to take into account the virtual offsets // (See getNextLocationOffset and getLocationOffset) // We should add to childTop: // sum([getNextLocationOffset(getChildAt(i)) / i < mBaselineAlignedChildIndex]) // and also add: // getLocationOffset(child) int childTop = mBaselineChildTop; if (mOrientation == VERTICAL) { final int majorGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK; if (majorGravity != Gravity.TOP) { switch (majorGravity) { case Gravity.BOTTOM: childTop = getBottom() - getTop() - getPaddingBottom() - mTotalLength; break; case Gravity.CENTER_VERTICAL: childTop += ((getBottom() - getTop() - getPaddingTop() - getPaddingBottom()) - mTotalLength) / 2; break; } } } LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams(); return childTop + lp.topMargin + childBaseline; }
From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java
/** * Enable or disable interaction with the given drawer. * //w ww .j a va 2s . c o m * <p> * This allows the application to restrict the user's ability to open or * close the given drawer. DrawerLayout will still respond to calls to * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a * drawer is locked. * </p> * * <p> * Locking a drawer open or closed will implicitly open or close that drawer * as appropriate. * </p> * * @param lockMode * The new lock mode for the given drawer. One of * {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} * or {@link #LOCK_MODE_LOCKED_OPEN}. * @param edgeGravity * Gravity.LEFT, RIGHT, START or END. Expresses which drawer to * change the mode for. * * @see #LOCK_MODE_UNLOCKED * @see #LOCK_MODE_LOCKED_CLOSED * @see #LOCK_MODE_LOCKED_OPEN */ public void setDrawerLockMode(int lockMode, int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); final ViewDragHelper helper; switch (absGravity) { case Gravity.LEFT: mLockModeLeft = lockMode; helper = mLeftDragger; break; case Gravity.RIGHT: mLockModeRight = lockMode; helper = mRightDragger; break; case Gravity.TOP: mLockModeTop = lockMode; helper = mTopDragger; break; case Gravity.BOTTOM: mLockModeBottom = lockMode; helper = mBottomDragger; break; default: helper = mBottomDragger; break; } if (lockMode != LOCK_MODE_UNLOCKED) { // Cancel interaction in progress helper.cancel(); } switch (lockMode) { case LOCK_MODE_LOCKED_OPEN: final View toOpen = findDrawerWithGravity(absGravity); if (toOpen != null) { openDrawer(toOpen); } break; case LOCK_MODE_LOCKED_CLOSED: final View toClose = findDrawerWithGravity(absGravity); if (toClose != null) { closeDrawer(toClose); } break; // default: do nothing } }
From source file:com.google.blockly.android.ToolboxFragment.java
/** * @return True if {@link #mTabEdge} is {@link Gravity#TOP} or {@link Gravity#BOTTOM}. *//*from w w w .ja v a 2 s . c o m*/ protected boolean isTabsHorizontal() { return (mTabEdge == Gravity.TOP || mTabEdge == Gravity.BOTTOM); }
From source file:com.netease.qa.emmagee.service.EmmageeService.java
/** * create a floating window to show real-time data. *///from w w w.ja v a 2s. c om private void createFloatingWindow() { SharedPreferences shared = getSharedPreferences("float_flag", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = shared.edit(); editor.putInt("float", 1); editor.commit(); windowManager = (WindowManager) getApplicationContext().getSystemService("window"); wmParams = ((MyApplication) getApplication()).getMywmParams(); wmParams.type = 2002; wmParams.flags |= 8; wmParams.gravity = Gravity.LEFT | Gravity.TOP; wmParams.x = 0; wmParams.y = 0; wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.format = 1; windowManager.addView(viFloatingWindow, wmParams); viFloatingWindow.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { x = event.getRawX(); y = event.getRawY() - statusBarHeight; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mTouchStartX = event.getX(); mTouchStartY = event.getY(); break; case MotionEvent.ACTION_MOVE: updateViewPosition(); break; case MotionEvent.ACTION_UP: updateViewPosition(); mTouchStartX = mTouchStartY = 0; break; } return true; } }); btnWifi.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi); String buttonText = (String) btnWifi.getText(); String wifiText = getResources().getString(R.string.open_wifi); if (buttonText.equals(wifiText)) { wifiManager.setWifiEnabled(true); btnWifi.setText(R.string.close_wifi); } else { wifiManager.setWifiEnabled(false); btnWifi.setText(R.string.open_wifi); } } catch (Exception e) { Toast.makeText(viFloatingWindow.getContext(), getString(R.string.wifi_fail_toast), Toast.LENGTH_LONG).show(); Log.e(LOG_TAG, e.toString()); } } }); }
From source file:com.ikode.viezara.ikode.HelpPage.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_help_page); listView = (ListView) findViewById(R.id.list); searchBox = (SearchView) findViewById(R.id.searchbox); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, titles); listView.setAdapter(adapter);//from www .j av a2 s. c om searchBox.setOnQueryTextListener(new SearchView.OnQueryTextListener() { public boolean onQueryTextSubmit(String query) { // TODO Auto-generated method stub return false; } public boolean onQueryTextChange(String query) { // TODO Auto-generated method stub adapter.getFilter().filter(query); return false; } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String chosenTitle = ((TextView) view).getText().toString(); String titleValue = getValue(chosenTitle); TextView tx = new TextView(HelpPage.this); tx.setText(titleValue); tx.setGravity(Gravity.TOP); new AlertDialog.Builder(HelpPage.this).setTitle("MESSAGE").setMessage("CONTENT: ") .setView(tx, 25, 0, 25, 0) .setNegativeButton("CLOSE", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).show(); } }); //Toolbar toolbar = (Toolbar) findViewById(R.id.ikode_bar); // setSupportActionBar(toolbar); //test for returning to previous activity // getSupportActionBar().setHomeButtonEnabled(true); //getSupportActionBar().setDisplayHomeAsUpEnabled(true); /* try { parseData(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "ERROR: " + e.getMessage(), Toast.LENGTH_LONG).show(); } */ //ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.Layout.simple_List_item_1, searches ); /*SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); ComponentName componentName = new ComponentName(context, HelpPage.class); searchView.setSearchableInfo(searchManager.getSearchableInfo(componentName));*/ }
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
/** * Check the lock mode of the given drawer view. * * @param drawerView Drawer view to check lock mode * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. */// ww w .j av a2 s . c o m public int getDrawerLockMode(View drawerView) { final int gravity = getDrawerViewGravity(drawerView); if (gravity == Gravity.TOP) { return mLockModeTop; } else if (gravity == Gravity.BOTTOM) { return mLockModeBottom; } return LOCK_MODE_UNLOCKED; }
From source file:com.scoreflex.ScoreflexView.java
/** * Closes this ScoreflexView. If the view is attached to the developer * hierarchy it will be detached. If the view is attached to a * ScoreflexActivity, this activity will be terminated. *//*from ww w . ja v a2s. c o m*/ public void close() { // If we're displayed in the developer view hierarchy, // remove ourselves. final ViewParent parent = this.getParent(); ViewGroup.LayoutParams currentLayoutParams = getLayoutParams(); boolean isFullscreen = currentLayoutParams.height == LayoutParams.MATCH_PARENT; LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(mLoginReceiver); if (isFullscreen && null != parent && parent instanceof ViewGroup) { int gravity = getLayoutGravity(); int anim = (Gravity.TOP == (gravity & Gravity.VERTICAL_GRAVITY_MASK)) ? R.anim.scoreflex_exit_slide_up : R.anim.scoreflex_exit_slide_down; Animation animation = AnimationUtils.loadAnimation(mParentActivity, anim); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { ViewGroup parentGroup = (ViewGroup) parent; parentGroup.removeView(ScoreflexView.this); if (mScoreflexViewHandler != null) { mScoreflexViewHandler.onViewClosed(); mScoreflexViewHandler = null; } } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationStart(Animation arg0) { } }); startAnimation(animation); } else if (null != parent && parent instanceof ViewGroup) { ViewGroup parentGroup = (ViewGroup) parent; parentGroup.removeView(this); if (mScoreflexViewHandler != null) { mScoreflexViewHandler.onViewClosed(); mScoreflexViewHandler = null; } } }
From source file:com.linkbubble.ui.BubbleDraggable.java
public void configure(int x0, int y0, int targetX, int targetY, int targetTime, CanvasView cv) { try {//from w w w. j a v a 2 s. co m super.configure("http://blerg.com"); // the URL is not actually used... } catch (MalformedURLException e) { e.printStackTrace(); } //setBackgroundColor(0xff00ff00); mMode = Mode.BubbleView; mAnimActive = false; mHasMoved = false; mCanvasView = cv; mBadgeView = (BadgeView) findViewById(R.id.badge_view); mBadgeView.hide(); mBadgeView.setVisibility(View.GONE); mCircle = new Circle(0, 0, 1); int bubbleSize = getResources().getDimensionPixelSize(R.dimen.bubble_size); WindowManager.LayoutParams windowManagerParams = new WindowManager.LayoutParams(); windowManagerParams.gravity = Gravity.TOP | Gravity.LEFT; windowManagerParams.x = x0; windowManagerParams.y = y0; windowManagerParams.height = bubbleSize; windowManagerParams.width = bubbleSize; windowManagerParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; windowManagerParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; windowManagerParams.format = PixelFormat.TRANSPARENT; windowManagerParams.setTitle("LinkBubble: BubbleDraggable"); final MainController controller = MainController.get(); mDraggableHelper = new DraggableHelper(this, windowManagerParams, true, new DraggableHelper.OnTouchActionEventListener() { @Override public void onActionDown(DraggableHelper.TouchEvent e) { if (!mAnimActive) { mCurrentSnapTarget = null; mHasMoved = false; mTouchDown = true; mTouchInitialX = e.posX; mTouchInitialY = e.posY; animate().alpha(1.0f).setDuration(Constant.BUBBLE_ANIM_TIME); mBadgeView.animate().alpha(1.0f).setDuration(Constant.BUBBLE_ANIM_TIME); MainController mainController = MainController.get(); if (mainController != null) { mainController.scheduleUpdate(); } MainApplication.postEvent(getContext(), mBeginBubbleDragEvent); CrashTracking.log("BubbleDraggable.configure(): onActionDown() - start drag"); } } @Override public void onActionMove(DraggableHelper.MoveEvent e) { Log.d(TAG, "!!!!!Moving"); if (mTouchDown) { setVisibility(View.VISIBLE); int targetX = targetX = (int) (e.rawX - Config.mBubbleWidth * 0.5); int targetY = (int) (e.rawY - Config.mBubbleHeight); targetX = Util.clamp(Config.mBubbleSnapLeftX, targetX, Config.mBubbleSnapRightX); targetY = Util.clamp(Config.mBubbleMinY, targetY, Config.mBubbleMaxY); float d = (float) Math.sqrt((e.dx * e.dx) + (e.dy * e.dy)); if (d >= Config.dpToPx(10.0f)) { mHasMoved = true; } if (!mAnimActive) { // c = null, t = null wasn't snapping, no snap -> move // c = 1, t = null was snapping, no snap -> anim out // c = null, t = 1 wasn't snapping, is snap -> anim in // c = 1, t = 1 was snapping, is snapping -> NO move mCircle.Update(targetX + Config.mBubbleWidth * 0.5f, targetY + Config.mBubbleHeight * 0.5f, Config.mBubbleWidth * 0.5f); BubbleTargetView tv = mCanvasView.getSnapTarget(mCircle, 1.0f); if (mCurrentSnapTarget == null) { if (tv == null) { setTargetPos(targetX, targetY, 0.0f, DraggableHelper.AnimationType.DistanceProportion, false, null); } else { tv.beginSnapping(); mCurrentSnapTarget = tv; mTimeOnSnapTarget = 0.0f; Circle dc = tv.GetDefaultCircle(); int xt = (int) (0.5f + dc.mX - Config.mBubbleWidth * 0.5f); int yt = (int) (0.5f + dc.mY - Config.mBubbleHeight * 0.5f); setTargetPos(xt, yt, Config.ANIMATE_TO_SNAP_TIME, DraggableHelper.AnimationType.Linear, false, new DraggableHelper.AnimationEventListener() { @Override public void onAnimationComplete() { onAnimComplete(); } @Override public void onCancel() { onAnimComplete(); } }); } } else { if (tv == null) { setTargetPos(targetX, targetY, 0.05f, DraggableHelper.AnimationType.Linear, false, new DraggableHelper.AnimationEventListener() { @Override public void onAnimationComplete() { mCurrentSnapTarget.endSnapping(); mCurrentSnapTarget.endLongHovering(); mCurrentSnapTarget = null; mTimeOnSnapTarget = 0.f; onAnimComplete(); } @Override public void onCancel() { onAnimComplete(); } }); } } } } } @Override public void onActionUp(DraggableHelper.ReleaseEvent e, boolean startDelay) { if (mTouchDown) { CrashTracking.log("BubbleDraggable.configure(): onActionUp() - end drag"); mDraggableHelper.cancelAnimation(); if (mHasMoved) { if (mCurrentSnapTarget == null) { float v = (float) Math.sqrt(e.vx * e.vx + e.vy * e.vy); float threshold = Config.dpToPx(900.0f); if (v > threshold) { doFlick(e.vx, e.vy); CrashTracking.log("BubbleDraggable.configure(): onActionUp() - doFlick()"); } else { boolean doBubbleView = mMode == Mode.BubbleView || e.posX < Config.mScreenWidth * 0.2f || e.posX > Config.mScreenWidth * 0.8f || e.posY > Config.mScreenHeight * 0.5f; if (doBubbleView) { mMode = Mode.BubbleView; } MainApplication.postEvent(getContext(), mEndBubbleDragEvent); if (doBubbleView) { CrashTracking .log("BubbleDraggable.configure(): onActionUp() - doSnap()"); doSnap(); } else { CrashTracking.log( "BubbleDraggable.configure(): onActionUp() - doAnimateToContentView() [mHasMoved==true]"); doAnimateToContentView(controller, startDelay); } } } else { MainApplication.postEvent(getContext(), mEndBubbleDragEvent); CrashTracking.log("BubbleDraggable.configure(): onActionUp() - doSnapAction()"); doSnapAction(mCurrentSnapTarget.getAction()); } } else { MainApplication.postEvent(getContext(), mEndBubbleDragEvent); if (mMode == Mode.BubbleView) { CrashTracking.log( "BubbleDraggable.configure(): onActionUp() - doAnimateToContentView() [mMode == Mode.BubbleView]"); doAnimateToContentView(controller, startDelay); } else { if (mMode == Mode.ContentView && mBubbleFlowDraggable.isExpanded() == false) { CrashTracking.log( "BubbleDraggable.configure(): onActionUp() - doAnimateToContentView() [mMode == Mode.ContentView]"); doAnimateToContentView(controller, startDelay); } else { CrashTracking.log( "BubbleDraggable.configure(): onActionUp() - doAnimateToBubbleView()"); doAnimateToBubbleView(0); } } } mTouchDown = false; } } }); if (mDraggableHelper.isAlive()) { MainController.addRootWindow(this, windowManagerParams); slideOnScreen(x0, y0, targetX, targetY, targetTime); } }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Init refresh view or loading view/*from w ww . j av a2 s . co m*/ */ private void setRefreshView() { // SetUp HeaderView FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 0); headerView = new WXRefreshView(getContext()); headerView.setStartEndTrim(0, 0.75f); headerView.setBackgroundColor(mRefreshViewBgColor); headerView.setProgressBgColor(mProgressBgColor); headerView.setProgressColor(mProgressColor); headerView.setContentGravity(Gravity.BOTTOM); addView(headerView, lp); // SetUp FooterView lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 0); lp.gravity = Gravity.BOTTOM; footerView = new WXRefreshView(getContext()); footerView.setStartEndTrim(0.5f, 1.25f); footerView.setBackgroundColor(mRefreshViewBgColor); footerView.setProgressBgColor(mProgressBgColor); footerView.setProgressColor(mProgressColor); footerView.setContentGravity(Gravity.TOP); addView(footerView, lp); }
From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java
private WindowManager.LayoutParams createFilterLayoutParams() { WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, mScreenManager.getScreenHeight(), 0, -mScreenManager.getStatusBarHeightPx(), WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, PixelFormat.TRANSLUCENT);//from ww w.j a va2s .co m wlp.gravity = Gravity.TOP | Gravity.START; wlp.buttonBrightness = mSettingsModel.getDimButtonsFlag() ? 0 : -1; return wlp; }