List of usage examples for android.view Gravity START
int START
To view the source code for android.view Gravity START.
Click Source Link
From source file:com.aniruddhc.acemusic.player.MainActivity.MainActivity.java
@Override public void onBackPressed() { if (mDrawerLayout.isDrawerOpen(Gravity.START)) { // Close left drawer if opened mDrawerLayout.closeDrawer(Gravity.START); } else if (getCurrentFragmentId() == Common.FOLDERS_FRAGMENT) { if (((FilesFoldersFragment) mCurrentFragment).getCurrentDir().equals("/")) super.onBackPressed(); else/*from w w w. ja v a2 s . co m*/ ((FilesFoldersFragment) mCurrentFragment).getParentDir(); } else { super.onBackPressed(); } }
From source file:fr.shywim.antoinedaniel.ui.MainActivity.java
private void onNavDrawerItemClick(@DrawerItem final int itemId) { // Delay to allow the drawer animation to play goToNavDrawerItem(itemId);//from w w w. j av a 2 s . c o m mDrawerLayout.closeDrawer(Gravity.START); }
From source file:com.htc.dotdesign.ToolBoxService.java
private void initDragButton() { //Initialize drag button if (mDragButton != null) { mCurrFuncIcon = (ImageView) mDragButton.findViewById(R.id.curr_func_icon); if (mDragBtnColorIcon != null) { mDragBtnColorIcon.setColor(mCurrBrushColor); mCurrFuncIcon.setBackground(mDragBtnColorIcon); }/*from w ww.jav a 2 s . c o m*/ mDragButton.setOnTouchListener(new OnTouchListener() { //private int initialX; private int initialY; private float initialTouchX; private float initialTouchY; private boolean mIsMoving = false; private boolean mIsTryMoving = false; @Override public boolean onTouch(View v, MotionEvent event) { Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch"); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch, ACTION_DOWN"); //initialX = mDragButtonParams.x; initialY = mDragButtonParams.y; initialTouchX = event.getRawX(); initialTouchY = event.getRawY(); break; case MotionEvent.ACTION_UP: Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch, ACTION_UP"); if (!mIsMoving && !mIsTryMoving) { if (!mbIsAnimationPlaying) { if (mIsToolBarOpen) { if (mIsToolBarExtend) { setToolPanelVisibility(false); } else { mToolBar.clearAnimation(); if (mCurrLayoutMode == LayoutMode.LEFT_SIDE) { playAnimation(mToolBar, mLeftOut); } else if (mCurrLayoutMode == LayoutMode.RIGHT_SIDE) { playAnimation(mToolBar, mRightOut); } } } else { if (mCurrLayoutMode == LayoutMode.LEFT_SIDE) { mToolBarParams.gravity = Gravity.START; } else if (mCurrLayoutMode == LayoutMode.RIGHT_SIDE) { mToolBarParams.gravity = Gravity.END; } mToolBarParams.gravity = Gravity.TOP | mToolBarParams.gravity; mToolBarParams.x = 0; mToolBarParams.y = mDragButtonParams.y; mWindowManager.updateViewLayout(mToolBarParent, mToolBarParams); mToolBarParent.setVisibility(View.VISIBLE); mToolBar.clearAnimation(); mToolBar.setVisibility(View.VISIBLE); if (mCurrLayoutMode == LayoutMode.LEFT_SIDE) { playAnimation(mToolBar, mLeftIn); } else if (mCurrLayoutMode == LayoutMode.RIGHT_SIDE) { playAnimation(mToolBar, mRightIn); } } } } else { mIsTryMoving = false; mIsMoving = false; /*if (mDragButtonParams.x <= mScreenWidth / 2) { mDragButtonParams.x = 0; mWindowManager.updateViewLayout(mDragButton, mDragButtonParams); mCurrLayoutMode = LayoutMode.LEFT_SIDE; } else { mDragButtonParams.x = mScreenWidth - mDragButtonWidth; mWindowManager.updateViewLayout(mDragButton, mDragButtonParams); mCurrLayoutMode = LayoutMode.RIGHT_SIDE; }*/ } // mDragButton.setBackgroundResource(R.drawable.floating2); break; case MotionEvent.ACTION_MOVE: Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onTouch, ACTION_MOVE, mToolBox.getHeight()" + mToolBar.getHeight()); if (Math.abs(event.getRawX() - initialTouchX) > 10 || Math.abs(event.getRawY() - initialTouchY) > 10) { mIsTryMoving = true; } if (/*!mIsToolBarExtend && */mIsTryMoving) { mIsMoving = true; // paramsF.x = initialX + (int) (event.getRawX() - initialTouchX); mDragButtonParams.y = initialY + (int) (event.getRawY() - initialTouchY); if (mDragButtonParams.y < 0) { mDragButtonParams.y = 0; } else if (mDragButtonParams.y > mScreenHeight - mDragButtonHeight) { mDragButtonParams.y = mScreenHeight - mDragButtonHeight; } mWindowManager.updateViewLayout(mDragButton, mDragButtonParams); // mDragButton.setBackgroundResource(R.drawable.ic_launcher); if (mIsToolBarOpen) { mToolBarParams.y = mDragButtonParams.y; mWindowManager.updateViewLayout(mToolBarParent, mToolBarParams); } if (mIsToolBarExtend) { setToolPanelVisibility(false); } } break; } return true; } }); } }
From source file:com.marlonjones.voidlauncher.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case VIEW_TYPE_ICON: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); icon.setAccessibilityDelegate(mLauncher.getAccessibilityDelegate()); break;//from w ww . j a va 2 s .c om } case VIEW_TYPE_PREDICTION_ICON: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); icon.setAccessibilityDelegate(mLauncher.getAccessibilityDelegate()); break; } case VIEW_TYPE_EMPTY_SEARCH: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case VIEW_TYPE_SEARCH_MARKET: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); } else { searchView.setVisibility(View.GONE); } break; } if (mBindViewCallback != null) { mBindViewCallback.onBindView(holder); } }
From source file:com.android.mail.ui.TwoPaneLayout.java
@Override public void onViewModeChanged(int newMode) { // make all initially GONE panes visible only when the view mode is first determined if (mCurrentMode == ViewMode.UNKNOWN) { mFoldersView.setVisibility(VISIBLE); mListView.setVisibility(VISIBLE); mListCopyView.setVisibility(VISIBLE); }/*from w ww. ja v a 2s . c om*/ if (ViewMode.isAdMode(newMode)) { mMiscellaneousView.setVisibility(VISIBLE); mConversationView.setVisibility(GONE); } else { mConversationView.setVisibility(VISIBLE); mMiscellaneousView.setVisibility(GONE); } // set up the drawer as appropriate for the configuration final ViewParent foldersParent = mFoldersView.getParent(); if (mIsExpansiveLayout && foldersParent != this) { if (foldersParent != mDrawerLayout) { throw new IllegalStateException("invalid Folders fragment parent: " + foldersParent); } mDrawerLayout.removeView(mFoldersView); addView(mFoldersView, 0); mFoldersView.findViewById(R.id.folders_pane_edge).setVisibility(VISIBLE); mFoldersView.setBackgroundDrawable(null); } else if (!mIsExpansiveLayout && foldersParent == this) { removeView(mFoldersView); mDrawerLayout.addView(mFoldersView); final DrawerLayout.LayoutParams lp = (DrawerLayout.LayoutParams) mFoldersView.getLayoutParams(); lp.gravity = Gravity.START; mFoldersView.setLayoutParams(lp); mFoldersView.findViewById(R.id.folders_pane_edge).setVisibility(GONE); mFoldersView.setBackgroundResource(R.color.list_background_color); } // detach the pager immediately from its data source (to prevent processing updates) if (ViewMode.isConversationMode(mCurrentMode)) { mController.disablePagerUpdates(); } mDrawerInitialSetupComplete = true; mCurrentMode = newMode; LogUtils.i(LOG_TAG, "onViewModeChanged(%d)", newMode); // do all the real work in onMeasure/onLayout, when panes are sized and positioned for the // current width/height anyway requestLayout(); }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break;/*from w w w .j a va2 s.c o m*/ } case PREDICTION_ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break; } case EMPTY_SEARCH_VIEW_TYPE: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case SEARCH_MARKET_VIEW_TYPE: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); searchView.setContentDescription(mMarketSearchMessage); searchView.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); searchView.setText(mMarketSearchMessage); } else { searchView.setVisibility(View.GONE); } break; } }
From source file:com.facebook.litho.widget.TextSpec.java
private static Alignment getAlignment(int gravity) { final Alignment alignment; switch (gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.START: alignment = ALIGN_NORMAL;//from w ww .java2 s. c o m break; case Gravity.END: alignment = ALIGN_OPPOSITE; break; case Gravity.LEFT: // unsupported, default to normal alignment = ALIGN_NORMAL; break; case Gravity.RIGHT: // unsupported, default to opposite alignment = ALIGN_OPPOSITE; break; case Gravity.CENTER_HORIZONTAL: alignment = ALIGN_CENTER; break; default: alignment = textAlignment; break; } return alignment; }
From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java
public void init() { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(getApplicationContext()); mMediaPlayer.setScreenOnWhilePlaying(true); }/*from w ww . jav a2 s .co m*/ mHandler = new Handler(); mDecorView = getWindow().getDecorView(); mSeekbar = (SeekBar) findViewById(R.id.activity_main_seekbar); mSeekbar.setMax(1000); mPlayPauseButton = (ImageView) findViewById(R.id.activity_main_playpause_button); mSeekBarUpdater = new SeekbarUpdater(mSeekbar, mMediaPlayer); mTopLayout = (RelativeLayout) findViewById(R.id.activity_main_mainlayout); mTrackDialog = new AudioSubtitleTrackDialog(this); mAudioPos = mSubPos = 0; mTimeView = (TextView) findViewById(R.id.activity_main_time); mDurationView = (TextView) findViewById(R.id.activity_main_duration); mTimeLayout = (LinearLayout) findViewById(R.id.activity_main_timelayout); mTimeTracker = new TimeTracker(mMediaPlayer, mTimeView); mSubtitleView = (TextView) findViewById(R.id.activity_main_subtitleView); mSubtitleRenderer = new SubtitleRenderer(mSubtitleView, Looper.myLooper(), mMediaPlayer); mSubtitleLayoutAboveTimeView = (RelativeLayout.LayoutParams) mSubtitleView.getLayoutParams(); mSubtitleLayoutBottom = (RelativeLayout.LayoutParams) ((TextView) findViewById( R.id.activity_main_subtitleView_params)).getLayoutParams(); mTimeSeekView = (TextView) findViewById(R.id.activity_main_time_seek); mMediaPlayer.setOnInfoListener(this); RelativeLayout browsingL = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout); ExpandableListView elv = (ExpandableListView) browsingL.findViewById(R.id.file_browsing_exp_list_view); ListView lv = (ListView) browsingL.findViewById(R.id.file_browsing_listview); RelativeLayout debugLayout = (RelativeLayout) findViewById(R.id.activity_main_debug_view); LinearLayout debugLinearLayout = (LinearLayout) debugLayout.findViewById(R.id.activity_main_debug_linear); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setScrimColor(Color.TRANSPARENT); mDrawerLayout.setDrawerListener(this); mFileBrowser = new MediaBrowser(this, elv, lv, mMediaPlayer, (MainActivity) this, mDrawerLayout, debugLinearLayout); mIsFileBrowsing = false; mPreview = (SurfaceView) findViewById(R.id.mSurfaceView); mPreview.setOnTouchListener(this); mTopLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); mPreview.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); mSubtitleTracker = new HashMap<Integer, Integer>(); mAudioTracker = new HashMap<Integer, Integer>(); findViewById(R.id.activity_main_loading_panel).bringToFront(); findViewById(R.id.activity_main_browsing_layout).bringToFront(); mUpperControls = (RelativeLayout) findViewById(R.id.UpperButtonLayout); mBottomControls = (RelativeLayout) findViewById(R.id.ButtonLayout); mSlideInAnimation = AnimationUtils.loadAnimation(this, R.anim.in_top); mSlideInAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mUpperControls.setVisibility(View.VISIBLE); Runnable r = new Runnable() { @Override public void run() { mBottomControls.setVisibility(View.INVISIBLE); } }; mHandler.postDelayed(r, 3500); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mBottomControls.setVisibility(View.INVISIBLE); } }); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mFadeOutRunnable = new Runnable() { @Override public void run() { mSeekbar.setEnabled(false); Animation fadeoutBottom = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_bottom); fadeoutBottom.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mOngoingAnimation) { mOngoingAnimation = false; mBottomControls.setVisibility(View.INVISIBLE); mUpperControls.setVisibility(View.INVISIBLE); mSeekbar.setVisibility(View.GONE); mTimeLayout.setVisibility(View.GONE); mSubtitleView.setLayoutParams(mSubtitleLayoutBottom); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mOngoingAnimation = true; } }); Animation fadeoutTop = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_top); mBottomControls.startAnimation(fadeoutBottom); mUpperControls.startAnimation(fadeoutTop); mSeekbar.startAnimation(fadeoutBottom); mTimeLayout.startAnimation(fadeoutBottom); } }; mHideNavigationRunnable = new Runnable() { @Override public void run() { mPreview.setSystemUiVisibility(mUiOptions); } }; mDecorView.setOnSystemUiVisibilityChangeListener(this); mSeekbar.setOnSeekBarChangeListener(new OwnOnSeekBarChangeListener(mMediaPlayer)); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnSubtitleDataListener(this); RelativeLayout browsingLayout = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout); DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) browsingLayout.getLayoutParams(); Resources resources = getResources(); int top = 0; int bottom = 0; RelativeLayout.LayoutParams tempParams; int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { top = resources.getDimensionPixelSize(resourceId); } resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { bottom = resources.getDimensionPixelSize(resourceId); } if (navigationBarAtBottom()) { tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams(); tempParams.bottomMargin += bottom; mBottomControls.setLayoutParams(tempParams); tempParams = (RelativeLayout.LayoutParams) mSeekbar.getLayoutParams(); tempParams.bottomMargin += bottom; mSeekbar.setLayoutParams(tempParams); params.setMargins(0, top, 0, bottom); } else { tempParams = (RelativeLayout.LayoutParams) mBottomControls.getLayoutParams(); tempParams.rightMargin += bottom; mBottomControls.setLayoutParams(tempParams); params.setMargins(0, top, 0, 0); } browsingLayout.setLayoutParams(params); mDrawerLayout.openDrawer(Gravity.START); mMediaPlayer.setOnOutputControlListener(this); }
From source file:ru.moscow.tuzlukov.sergey.weatherlog.MainActivity.java
private void makePlot(double minTemp, double maxTemp) { //all graphics should have a room, to be visible in plot viewport, i.e. max from greatest and min from the least ordinates: double lowLimit = Math.min(Math.round(minTemp), temperatureLimit2); double highLimit = Math.max(Math.round(maxTemp), temperatureLimit1); //round for drawing scale with 5-degrees step: lowLimit = Math.floor(lowLimit / 5.0) * 5.0; highLimit = Math.ceil(highLimit / 5.0) * 5.0; //fill in the plot with all data series: List<DataPoint> dataPoints = new ArrayList<>(); for (Long time : temperatureMap.keySet()) dataPoints.add(new DataPoint(time, temperatureMap.get(time))); dataPoints.add(new DataPoint(currentTime, dataPoints.get(dataPoints.size() - 1).getY())); //fix for using data from cache LineGraphSeries<DataPoint> temperatureSeries = new LineGraphSeries<>( dataPoints.toArray(new DataPoint[dataPoints.size()])); LineGraphSeries<DataPoint> temperatureLimit1Series = new LineGraphSeries<>( new DataPoint[] { new DataPoint(currentTimeMinus24h, temperatureLimit1), new DataPoint(currentTime, temperatureLimit1) }); LineGraphSeries<DataPoint> temperatureLimit2Series = new LineGraphSeries<>( new DataPoint[] { new DataPoint(currentTimeMinus24h, temperatureLimit2), new DataPoint(currentTime, temperatureLimit2) }); graphView.addSeries(temperatureSeries); graphView.addSeries(temperatureLimit1Series); graphView.addSeries(temperatureLimit2Series); //lay out the plot: GridLabelRenderer gridLabelRenderer = graphView.getGridLabelRenderer(); Viewport viewport = graphView.getViewport(); //adjust grid settings: gridLabelRenderer.setGridStyle(GridLabelRenderer.GridStyle.BOTH); gridLabelRenderer.setHighlightZeroLines(true); gridLabelRenderer.setHorizontalLabelsVisible(false); gridLabelRenderer.setVerticalLabelsVisible(true); //tune view of lines: viewport.setBackgroundColor(getResources().getColor(R.color.plot_viewport_background_color)); temperatureSeries.setColor(getResources().getColor(R.color.temperature_series_color)); temperatureSeries.setThickness(2);// ww w . j a v a2 s. com temperatureLimit1Series.setColor(getResources().getColor(R.color.limit1_series_color)); temperatureLimit1Series.setThickness(2); temperatureLimit2Series.setColor(getResources().getColor(R.color.limit2_series_color)); temperatureLimit2Series.setThickness(2); //set viewport bounds and set the scale: //...in horizontal: gridLabelRenderer.setNumHorizontalLabels(2); viewport.setMinX(currentTimeMinus24h); viewport.setMaxX(currentTime); viewport.setXAxisBoundsManual(true); //...in vertical: int numVerticalLabels = (int) (highLimit - lowLimit) / 5 + 1; numVerticalLabels = numVerticalLabels < 2 ? 2 : numVerticalLabels; gridLabelRenderer.setNumVerticalLabels(numVerticalLabels); viewport.setMinY(lowLimit); viewport.setMaxY(highLimit); viewport.setYAxisBoundsManual(true); //set horizontal labels: LinearLayout llHorizontalLabels = (LinearLayout) findViewById(R.id.llHorizontalLabels); if (llHorizontalLabels.getChildCount() == 0) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llHorizontalLabels.getLayoutParams(); params.bottomMargin = 0; llHorizontalLabels.setLayoutParams(params); gridLabelRenderer.setTextSize(gridLabelRenderer.getTextSize() - 2); //make text a bit smaller for (int n = -24; n < 0; n += 3) { TextView textView = new TextView(MainActivity.this); textView.setText(String.valueOf(n)); textView.setGravity(Gravity.START); textView.setSingleLine(); params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f / 8.0f); textView.setLayoutParams(params); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, gridLabelRenderer.getTextSize()); textView.setTextColor(gridLabelRenderer.getVerticalLabelsColor()); llHorizontalLabels.addView(textView); } TextView tvZeroLabel = (TextView) findViewById(R.id.tvZeroLabel); tvZeroLabel.setText("-0 " + getString(R.string.hours_caption)); tvZeroLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, gridLabelRenderer.getTextSize()); tvZeroLabel.setTextColor(gridLabelRenderer.getVerticalLabelsColor()); tvZeroLabel.setVisibility(View.VISIBLE); gridLabelRenderer.setPadding(gridLabelRenderer.getPadding() + 2); //make plot a bit smaller } }
From source file:com.cleveroad.audiowidget.AudioWidget.java
private void show(View view, int left, int top) { if (view.getParent() != null || view.getWindowToken() != null) { windowManager.removeView(view);/* w ww . j a va 2s. c o m*/ } WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSLUCENT); params.gravity = Gravity.START | Gravity.TOP; params.x = left; params.y = top; windowManager.addView(view, params); }