Java Code Examples for android.view.Gravity
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 2
From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 3
From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 4
public View createContentView(View view){ FrameLayout root=new FrameLayout(this); root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)); LinearLayout pframe=new LinearLayout(this); pframe.setId(R.id.INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setGravity(Gravity.CENTER); ProgressBar progress=new ProgressBar(this,null,android.R.attr.progressBarStyleLarge); pframe.addView(progress,new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe,new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)); FrameLayout lframe=new FrameLayout(this); lframe.setId(R.id.INTERNAL_FRAGMENT_CONTAINER_ID); lframe.setVisibility(View.GONE); lframe.addView(view,new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe,new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
Example 5
From project Alerte-voirie-android, under directory /src/net/londatiga/android/.
Source file: CustomPopupWindow.java

/** * Displays like a QuickAction from the anchor view. * @param xOffset offset in the X direction * @param yOffset offset in the Y direction */ public void showLikeQuickAction(int xOffset,int yOffset){ preShow(); window.setAnimationStyle(R.style.Animations_PopUpMenu_Center); int[] location=new int[2]; anchor.getLocationOnScreen(location); Rect anchorRect=new Rect(location[0],location[1],location[0] + anchor.getWidth(),location[1] + anchor.getHeight()); root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); root.measure(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); int rootWidth=root.getMeasuredWidth(); int rootHeight=root.getMeasuredHeight(); int screenWidth=windowManager.getDefaultDisplay().getWidth(); int xPos=((screenWidth - rootWidth) / 2) + xOffset; int yPos=anchorRect.top - rootHeight + yOffset; if (rootHeight > anchorRect.top) { yPos=anchorRect.bottom + yOffset; window.setAnimationStyle(R.style.Animations_PopDownMenu_Center); } window.showAtLocation(anchor,Gravity.NO_GRAVITY,xPos,yPos); }
Example 6
From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 7
From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/mynote/.
Source file: MyNoteEditTextView.java

public MyNoteEditTextView(Context context){ super(context); setSingleLine(false); LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); setLayoutParams(layoutParams); setGravity(Gravity.TOP); applyPreferenceSettings(); }
Example 8
From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 9
From project android-bankdroid, under directory /src/com/liato/bankdroid/.
Source file: BetterPopupWindow.java

/** * Displays like a QuickAction from the anchor view. * @param xOffset offset in the X direction * @param yOffset offset in the Y direction */ public void showLikeQuickAction(int xOffset,int yOffset){ this.preShow(); this.window.setAnimationStyle(R.style.Animations_GrowFromBottom); int[] location=new int[2]; this.anchor.getLocationOnScreen(location); Rect anchorRect=new Rect(location[0],location[1],location[0] + this.anchor.getWidth(),location[1] + this.anchor.getHeight()); this.root.measure(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); int rootWidth=this.root.getMeasuredWidth(); int rootHeight=this.root.getMeasuredHeight(); int screenWidth=this.windowManager.getDefaultDisplay().getWidth(); int screenHeight=this.windowManager.getDefaultDisplay().getHeight(); int xPos=((screenWidth - rootWidth) / 2) + xOffset; int yPos=anchorRect.top - rootHeight + yOffset; if (rootHeight > anchorRect.top) { yPos=anchorRect.bottom - yOffset; this.window.setAnimationStyle(R.style.Animations_GrowFromTop); this.root.findViewById(R.id.layPopupCont).setBackgroundResource(R.drawable.popup_bg_up); } this.window.showAtLocation(this.anchor,Gravity.NO_GRAVITY,xPos,yPos); }
Example 10
From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.
Source file: DialogHandler.java

private View createHoldingFileDialog(){ getDialog().getWindow().setGravity(Gravity.LEFT | Gravity.TOP); getDialog().setTitle("Holding " + mFiles.size() + " files"); ListView list=new ListView(mContext); list.setAdapter(new DialogListAdapter(mContext,R.layout.dir_list_layout,mFiles)); return list; }
Example 11
From project android-flip, under directory /FlipView/Demo/src/com/aphidmobile/flip/demo/views/.
Source file: NumberTextView.java

public NumberTextView(Context context,int number){ super(context); setNumber(number); setTextColor(Color.BLACK); setBackgroundColor(Color.WHITE); setGravity(Gravity.CENTER); }
Example 12
From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/dialogs/.
Source file: DialogHelper.java

public static void showHint(final Context c,String hintText,boolean makeItAQuickOne){ int duration=makeItAQuickOne ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG; Toast t=Toast.makeText(c,hintText,duration); t.setGravity(Gravity.CENTER_VERTICAL,0,0); t.show(); }
Example 13
From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/.
Source file: PageIndicator.java

private void initPageIndicator(){ mDotCount=MIN_DOT_COUNT; mGravity=Gravity.CENTER; mActiveDot=0; mDotSpacing=0; mDotType=DotType.SINGLE; mExtraState=onCreateDrawableState(1); mergeDrawableStates(mExtraState,SELECTED_STATE_SET); }
Example 14
From project android-mapviewballoons, under directory /android-mapviewballoons/src/com/readystatesoftware/mapviewballoons/.
Source file: BalloonOverlayView.java

/** * Create a new BalloonOverlayView. * @param context - The activity context. * @param balloonBottomOffset - The bottom padding (in pixels) to be appliedwhen rendering this view. */ public BalloonOverlayView(Context context,int balloonBottomOffset){ super(context); setPadding(10,0,10,balloonBottomOffset); layout=new LimitLinearLayout(context); layout.setVisibility(VISIBLE); setupView(context,layout); FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); params.gravity=Gravity.NO_GRAVITY; addView(layout,params); }
Example 15
From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.
Source file: CaptureActivity.java

/** * Called when the shutter button is pressed in continuous mode. */ void onShutterButtonPressContinuous(){ isPaused=true; handler.stop(); beepManager.playBeepSoundAndVibrate(); if (lastResult != null) { handleOcrDecode(lastResult); } else { Toast toast=Toast.makeText(this,"OCR failed. Please try again.",Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP,0,0); toast.show(); resumeContinuousDecoding(); } }
Example 16
From project android-pulltorefresh, under directory /library/src/com/handmark/pulltorefresh/library/.
Source file: PullToRefreshAdapterViewBase.java

private void addIndicatorViews(){ Mode mode=getMode(); FrameLayout refreshableViewWrapper=getRefreshableViewWrapper(); if (mode.canPullDown() && null == mIndicatorIvTop) { mIndicatorIvTop=new IndicatorLayout(getContext(),Mode.PULL_DOWN_TO_REFRESH); FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin=getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity=Gravity.TOP | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvTop,params); } else if (!mode.canPullDown() && null != mIndicatorIvTop) { refreshableViewWrapper.removeView(mIndicatorIvTop); mIndicatorIvTop=null; } if (mode.canPullUp() && null == mIndicatorIvBottom) { mIndicatorIvBottom=new IndicatorLayout(getContext(),Mode.PULL_UP_TO_REFRESH); FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin=getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity=Gravity.BOTTOM | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvBottom,params); } else if (!mode.canPullUp() && null != mIndicatorIvBottom) { refreshableViewWrapper.removeView(mIndicatorIvBottom); mIndicatorIvBottom=null; } }
Example 17
From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/editor/activity/.
Source file: ColourPickerActivity.java

public View getView(int position,View convertView,ViewGroup parent){ LabelView view; if (convertView instanceof LabelView) { view=(LabelView)convertView; } else { view=new LabelView(ColourPickerActivity.this); view.setText("Abc"); view.setGravity(Gravity.CENTER); } view.setColourIndex(position); view.setIcon(null); return view; }
Example 18
From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.
Source file: Term.java

@Override public boolean onOptionsItemSelected(MenuItem item){ int id=item.getItemId(); if (id == R.id.menu_preferences) { doPreferences(); } else if (id == R.id.menu_new_window) { doCreateNewWindow(); } else if (id == R.id.menu_close_window) { confirmCloseWindow(); } else if (id == R.id.menu_window_list) { startActivityForResult(new Intent(this,WindowList.class),REQUEST_CHOOSE_WINDOW); } else if (id == R.id.menu_reset) { doResetTerminal(); Toast toast=Toast.makeText(this,R.string.reset_toast_notification,Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER,0,0); toast.show(); } else if (id == R.id.menu_send_email) { doEmailTranscript(); } else if (id == R.id.menu_special_keys) { doDocumentKeys(); } else if (id == R.id.menu_toggle_soft_keyboard) { doToggleSoftKeyboard(); } else if (id == R.id.menu_toggle_wakelock) { doToggleWakeLock(); } else if (id == R.id.menu_toggle_wifilock) { doToggleWifiLock(); } if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) { mActionBar.hide(); } return super.onOptionsItemSelected(item); }
Example 19
From project android-thaiime, under directory /latinime/src/com/android/inputmethod/keyboard/.
Source file: MiniKeyboardView.java

@Override public void showMoreKeysPanel(View parentView,Controller controller,int pointX,int pointY,PopupWindow window,KeyboardActionListener listener){ mController=controller; mListener=listener; final View container=(View)getParent(); final MiniKeyboard miniKeyboard=(MiniKeyboard)getKeyboard(); parentView.getLocationInWindow(mCoordinates); final int miniKeyboardLeft=pointX - miniKeyboard.getDefaultCoordX() + parentView.getPaddingLeft(); final int x=wrapUp(Math.max(0,Math.min(miniKeyboardLeft,parentView.getWidth() - miniKeyboard.mOccupiedWidth)) - container.getPaddingLeft() + mCoordinates[0],container.getMeasuredWidth(),0,parentView.getWidth()); final int y=pointY - (container.getMeasuredHeight() - container.getPaddingBottom()) + parentView.getPaddingTop() + mCoordinates[1]; window.setContentView(container); window.setWidth(container.getMeasuredWidth()); window.setHeight(container.getMeasuredHeight()); window.showAtLocation(parentView,Gravity.NO_GRAVITY,x,y); mOriginX=x + container.getPaddingLeft() - mCoordinates[0]; mOriginY=y + container.getPaddingTop() - mCoordinates[1]; }
Example 20
From project android-wheel, under directory /wheel/src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 21
From project android-wheel-datetime-picker, under directory /src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 22
From project android-wheel_1, under directory /wheel/src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 23
From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.
Source file: ShelvesActivity.java

private void showPopup(){ if (mPopup == null) { PopupWindow p=new PopupWindow(this); p.setFocusable(false); p.setContentView(mGridPosition); p.setWidth(ViewGroup.LayoutParams.FILL_PARENT); p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); p.setBackgroundDrawable(null); p.setAnimationStyle(R.style.PopupAnimation); mPopup=p; } if (mGrid.getWindowVisibility() == View.VISIBLE) { mPopup.showAtLocation(mGrid,Gravity.CENTER,0,0); } }
Example 24
From project AndroidLab, under directory /samples/AndroidLdapClient/src/com/unboundid/android/ldap/client/.
Source file: ViewEntry.java

/** * Generates the display for a generic entry. */ private void displayGeneric(){ logEnter(LOG_TAG,"displayGeneric"); setTitle("Entry " + entry.getDN()); final LinearLayout layout=(LinearLayout)findViewById(R.id.layout_view_entry_panel); final HeaderClickListener hdrListener=new HeaderClickListener(this,entry); final LinearLayout l=new LinearLayout(this); l.setPadding(0,5,0,20); l.setOrientation(LinearLayout.VERTICAL); final TextView dnNameView=new TextView(this); dnNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP,12.0f); dnNameView.setText(getDisplayName(this,"DN")); dnNameView.setGravity(Gravity.LEFT); dnNameView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.FILL_PARENT)); l.addView(dnNameView); final TextView dnValueView=new TextView(this); dnValueView.setTextSize(TypedValue.COMPLEX_UNIT_SP,16.0f); dnValueView.setText(entry.getDN()); dnValueView.setGravity(Gravity.RIGHT); dnValueView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT)); l.addView(dnValueView); l.setOnClickListener(hdrListener); layout.addView(l); for ( final Attribute a : entry.getAttributes()) { if (a.hasValue()) { addGenericAttribute(a,layout); } } }
Example 25
From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 26
From project Android_1, under directory /LeftNavBarExample/LeftNavBarExample/src/novoda/demo/.
Source file: LeftNavBarWrapper.java

private static int nextGravity(int gravity,boolean horizontal){ int hGravity=gravity & Gravity.HORIZONTAL_GRAVITY_MASK; int vGravity=gravity & Gravity.VERTICAL_GRAVITY_MASK; if (horizontal) { switch (hGravity) { case Gravity.LEFT: hGravity=Gravity.CENTER_HORIZONTAL; break; case Gravity.CENTER_HORIZONTAL: hGravity=Gravity.RIGHT; break; case Gravity.RIGHT: default : hGravity=Gravity.LEFT; break; } } else { switch (vGravity) { case Gravity.TOP: vGravity=Gravity.CENTER_VERTICAL; break; case Gravity.CENTER_VERTICAL: vGravity=Gravity.BOTTOM; break; case Gravity.BOTTOM: default : vGravity=Gravity.TOP; break; } } return hGravity | vGravity; }
Example 27
From project android_7, under directory /src/org/immopoly/android/widget/.
Source file: ViewPager.java

public LayoutParams(Context context,AttributeSet attrs){ super(context,attrs); final TypedArray a=context.obtainStyledAttributes(attrs,LAYOUT_ATTRS); gravity=a.getInteger(0,Gravity.NO_GRAVITY); a.recycle(); }
Example 28
private void startDrag(int itemIndex,int y){ stopDrag(itemIndex); final View item=getChildAt(itemIndex); if (item == null) return; item.setDrawingCacheEnabled(true); if (mDragListener != null) mDragListener.onStartDrag(item); final Bitmap bitmap=Bitmap.createBitmap(item.getDrawingCache()); final WindowManager.LayoutParams mWindowParams=new WindowManager.LayoutParams(); mWindowParams.gravity=Gravity.TOP; mWindowParams.x=0; mWindowParams.y=y - mDragPointOffset; mWindowParams.height=WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width=WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; mWindowParams.format=PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations=0; final Context context=getContext(); final ImageView v=new ImageView(context); v.setImageBitmap(bitmap); final WindowManager mWindowManager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE); mWindowManager.addView(v,mWindowParams); mDragView=v; }
Example 29
From project android_ioio_combination_lock, under directory /src/kankan/wheel/widget/adapters/.
Source file: AbstractWheelTextAdapter.java

/** * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views. * @param view the text view to be configured */ protected void configureTextView(TextView view){ view.setTextColor(textColor); view.setGravity(Gravity.CENTER); view.setTextSize(textSize); view.setLines(1); view.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); }
Example 30
From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.
Source file: LightLevelsActivity.java

private TextView createTextView(int id,String text){ TextView tv=new TextView(this); tv.setGravity(Gravity.CENTER); tv.setText(text); tv.setWidth(dp2px(60)); tv.setId(id); return tv; }
Example 31
From project android_packages_apps_CMSettings, under directory /src/com/cyanogenmod/settings/activities/.
Source file: LightLevelsActivity.java

private TextView createTextView(int id,String text){ TextView tv=new TextView(this); tv.setGravity(Gravity.CENTER); tv.setText(text); tv.setWidth(dp2px(60)); tv.setId(id); return tv; }
Example 32
From project android_packages_apps_Gallery, under directory /src/com/android/camera/.
Source file: OnScreenHint.java

private synchronized void handleShow(){ if (mView != mNextView) { handleHide(); mView=mNextView; final int gravity=mGravity; mParams.gravity=gravity; if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) { mParams.horizontalWeight=1.0f; } if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) { mParams.verticalWeight=1.0f; } mParams.x=mX; mParams.y=mY; mParams.verticalMargin=mVerticalMargin; mParams.horizontalMargin=mHorizontalMargin; if (mView.getParent() != null) { mWM.removeView(mView); } mWM.addView(mView,mParams); } }
Example 33
From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/app/.
Source file: MovieControllerOverlay.java

private TextView createOverlayTextView(Context context){ TextView view=new TextView(context); view.setGravity(Gravity.CENTER); view.setTextColor(0xFFFFFFFF); view.setPadding(0,15,0,15); return view; }
Example 34
From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/app/.
Source file: App.java

public void showToast(final String string,final int duration,final boolean centered){ mHandler.post(new Runnable(){ public void run(){ if (mToast != null) { mToast.cancel(); } mToast=Toast.makeText(mContext,string,duration); if (centered) { mToast.setGravity(Gravity.CENTER,0,0); } mToast.show(); } } ); }
Example 35
From project android_packages_apps_phone, under directory /src/com/android/phone/.
Source file: IccPanel.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Window winP=getWindow(); winP.setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE); winP.setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT); winP.setGravity(Gravity.CENTER); PhoneApp app=PhoneApp.getInstance(); mStatusBarManager=(StatusBarManager)app.getSystemService(Context.STATUS_BAR_SERVICE); requestWindowFeature(Window.FEATURE_NO_TITLE); }
Example 36
From project android_packages_apps_QiblaCompass, under directory /src/com/farsitel/qiblacompass/activities/.
Source file: AboutActivity.java

@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); ScrollView sv=new ScrollView(this); LinearLayout ll=new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); LinearLayout titleLinearLayout=new LinearLayout(this); titleLinearLayout.setGravity(Gravity.CENTER); TextView titleTextview=new TextView(this); titleTextview.setText(getResources().getString(R.string.about_title_text)); titleTextview.setTextSize(getResources().getDimension(R.dimen.about_text_size)); titleTextview.setTypeface(null,Typeface.BOLD); titleLinearLayout.addView(titleTextview); LinearLayout versionLinearLayout=new LinearLayout(this); versionLinearLayout.setGravity(Gravity.CENTER); TextView version=new TextView(this); version.setTextSize(getResources().getDimension(R.dimen.about_text_size)); version.setText(R.string.version); versionLinearLayout.addView(version); LinearLayout releaseDateLinearLayout=new LinearLayout(this); releaseDateLinearLayout.setGravity(Gravity.CENTER); TextView releaseDateTextView=new TextView(this); releaseDateTextView.setText(R.string.release_date); releaseDateTextView.setTextSize(getResources().getDimension(R.dimen.about_text_size)); releaseDateLinearLayout.addView(releaseDateTextView); TextView aboutTextView=new TextView(this); aboutTextView.setLineSpacing(1,(float)1.3); aboutTextView.setGravity(Gravity.LEFT); aboutTextView.setText(R.string.about_text); aboutTextView.setPadding(getResources().getDimensionPixelOffset(R.dimen.about_text_padding),getResources().getDimensionPixelOffset(R.dimen.about_text_padding),getResources().getDimensionPixelOffset(R.dimen.about_text_padding),getResources().getDimensionPixelOffset(R.dimen.about_text_padding)); aboutTextView.setTextSize(getResources().getDimension(R.dimen.about_text_size)); ll.addView(titleLinearLayout); ll.addView(aboutTextView); ll.addView(versionLinearLayout); ll.addView(releaseDateLinearLayout); sv.addView(ll); setContentView(sv); }
Example 37
From project android_packages_apps_SalvageParts, under directory /src/com/salvagemod/salvageparts/widgets/.
Source file: TouchInterceptor.java

private void startDragging(Bitmap bm,int y){ stopDragging(); mWindowParams=new WindowManager.LayoutParams(); mWindowParams.gravity=Gravity.TOP; mWindowParams.x=0; mWindowParams.y=y - mDragPoint + mCoordOffset; mWindowParams.height=WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width=WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; mWindowParams.format=PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations=0; Context context=getContext(); ImageView v=new ImageView(context); int backGroundColor=context.getResources().getColor(R.color.dragndrop_background); v.setBackgroundColor(backGroundColor); v.setImageBitmap(bm); mDragBitmap=bm; mWindowManager=(WindowManager)context.getSystemService("window"); mWindowManager.addView(v,mWindowParams); mDragView=v; }
Example 38
From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.
Source file: TagWriterActivity.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mNfcAdapter=NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter == null) { finish(); } mStatusText=new TextView(this); mStatusText.setGravity(Gravity.CENTER); mStatusText.setText(R.string.nfc_write_tag); mTagToWrite=getIntent().getIntExtra(EXTRA_TAG,0); if (mTagToWrite == 0) { throw new IllegalArgumentException("You must specify a tag to write"); } setContentView(mStatusText); }
Example 39
From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/keyboard/.
Source file: MiniKeyboardView.java

@Override public void showMoreKeysPanel(View parentView,Controller controller,int pointX,int pointY,PopupWindow window,KeyboardActionListener listener){ mController=controller; mListener=listener; final View container=(View)getParent(); final MiniKeyboard miniKeyboard=(MiniKeyboard)getKeyboard(); parentView.getLocationInWindow(mCoordinates); final int miniKeyboardLeft=pointX - miniKeyboard.getDefaultCoordX() + parentView.getPaddingLeft(); final int x=wrapUp(Math.max(0,Math.min(miniKeyboardLeft,parentView.getWidth() - miniKeyboard.mOccupiedWidth)) - container.getPaddingLeft() + mCoordinates[0],container.getMeasuredWidth(),0,parentView.getWidth()); final int y=pointY - (container.getMeasuredHeight() - container.getPaddingBottom()) + parentView.getPaddingTop() + mCoordinates[1]; window.setContentView(container); window.setWidth(container.getMeasuredWidth()); window.setHeight(container.getMeasuredHeight()); window.showAtLocation(parentView,Gravity.NO_GRAVITY,x,y); mOriginX=x + container.getPaddingLeft() - mCoordinates[0]; mOriginY=y + container.getPaddingTop() - mCoordinates[1]; }
Example 40
From project apps-for-android, under directory /BTClickLinkCompete/src/net/clc/bt/.
Source file: MultiScreenVideo.java

/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); self=this; Intent startingIntent=getIntent(); isMaster=startingIntent.getBooleanExtra("isMaster",false); int pos=MultiScreenVideoView.POSITION_LEFT; if (!isMaster) { pos=MultiScreenVideoView.POSITION_RIGHT; } mVideo=new MultiScreenVideoView(this,pos); mVideo.setVideoPath("/sdcard/android.mp4"); LinearLayout mLinearLayout=new LinearLayout(this); if (!isMaster) { mLinearLayout.setOrientation(LinearLayout.HORIZONTAL); mLinearLayout.setGravity(Gravity.RIGHT); mLinearLayout.setPadding(0,0,120,0); } mLinearLayout.addView(mVideo); setContentView(mLinearLayout); mConnection=new Connection(this,serviceReadyListener); }
Example 41
From project Barcamp-Bangalore-Android-App, under directory /slidingmenu/library/src/com/slidingmenu/lib/.
Source file: CustomViewAbove.java

public LayoutParams(Context context,AttributeSet attrs){ super(context,attrs); final TypedArray a=context.obtainStyledAttributes(attrs,LAYOUT_ATTRS); gravity=a.getInteger(0,Gravity.NO_GRAVITY); a.recycle(); }
Example 42
From project BazaarUtils, under directory /src/com/congenialmobile/widget/.
Source file: LazyImageView.java

private void initProgressBarLoadingView(Context context){ WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics=new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); int width=(int)((float)metrics.density * 36); ProgressBar pBar=new ProgressBar(context); pBar.setLayoutParams(new LayoutParams(width,width,Gravity.CENTER)); addView(pBar); }
Example 43
From project BBC-News-Reader, under directory /src/com/hlidskialf/android/preference/.
Source file: SeekBarPreference.java

@Override protected View onCreateDialogView(){ LinearLayout.LayoutParams params; LinearLayout layout=new LinearLayout(mContext); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(6,6,6,6); mSplashText=new TextView(mContext); if (mDialogMessage != null) mSplashText.setText(mDialogMessage); layout.addView(mSplashText); mValueText=new TextView(mContext); mValueText.setGravity(Gravity.CENTER_HORIZONTAL); mValueText.setTextSize(32); params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT); layout.addView(mValueText,params); mSeekBar=new SeekBar(mContext); mSeekBar.setOnSeekBarChangeListener(this); layout.addView(mSeekBar,new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT)); if (shouldPersist()) mValue=getPersistedInt(mDefault); mSeekBar.setMax(mMax); mSeekBar.setProgress(mValue); return layout; }
Example 44
From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/activities/alliances/.
Source file: UserAlliance.java

private LinearLayout entryRow(int resImg,String topText,String bottomText){ LinearLayout container=new LinearLayout(currentContext); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER_VERTICAL); container.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,(int)(ratio * 80))); ImageView icon=new ImageView(currentContext); icon.setImageResource(resImg); icon.setPadding((int)(ratio * 10),0,(int)(ratio * 10),0); LinearLayout textcontainer=new LinearLayout(currentContext); textcontainer.setOrientation(LinearLayout.VERTICAL); TextView top=new TextView(currentContext); top.setText(topText); top.setTextColor(Color.parseColor("#545859")); TextView bottom=new TextView(currentContext); bottom.setTextColor(Color.parseColor("#787A77")); bottom.setText(bottomText); bottom.setPadding(0,0,(int)(ratio * 5),0); textcontainer.addView(top); textcontainer.addView(bottom); container.addView(icon); container.addView(textcontainer); return container; }
Example 45
From project BF3-Battlelog, under directory /src/net/peterkuterna/android/apps/swipeytabs/.
Source file: SwipeyTabs.java

/** * Update the ellipsize of the text views */ private void updateEllipsize(){ if (mAdapter == null) { } final int count=mAdapter.getCount(); for (int i=0; i < count; i++) { TextView tab=(TextView)getChildAt(i); if (i < mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); } else if (i == mCurrentPos) { tab.setEllipsize(TruncateAt.END); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } else if (i > mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } } }
Example 46
From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.
Source file: CurrencyAmountView.java

@Override protected void onFinishInflate(){ super.onFinishInflate(); final Context context=getContext(); textView=(TextView)getChildAt(0); textView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); textView.setHintTextColor(lessSignificantColor); setHint(null); setValidateAmount(textView instanceof EditText); final TextViewListener textViewListener=new TextViewListener(); textView.addTextChangedListener(textViewListener); textView.setOnFocusChangeListener(textViewListener); textView.setOnEditorActionListener(textViewListener); contextButton=new View(context){ @Override protected void onMeasure( final int wMeasureSpec, final int hMeasureSpec){ setMeasuredDimension(textView.getCompoundPaddingRight(),textView.getMeasuredHeight()); } } ; final LayoutParams chooseViewParams=new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); chooseViewParams.gravity=Gravity.RIGHT; contextButton.setLayoutParams(chooseViewParams); this.addView(contextButton); setCurrencyCode(Constants.CURRENCY_CODE_BITCOIN); updateAppearance(); }
Example 47
public ButtonsView(Context context){ super(context); this.context=context; setVisibility(INVISIBLE); Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int h=display.getHeight() - display.getWidth(); setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,h,Gravity.BOTTOM)); cancel=button(R.drawable.cancel,doCancel,0); addView(cancel); ok=button(R.drawable.checkmark,doOk,1); addView(ok); setOkState(false); }
Example 48
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: TouchListView.java

private void startDragging(Bitmap bm,int x,int y){ stopDragging(); mWindowParams=new WindowManager.LayoutParams(); mWindowParams.gravity=Gravity.TOP | Gravity.LEFT; mWindowParams.x=x; mWindowParams.y=y - mDragPoint + mCoordOffset; mWindowParams.height=WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width=WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; mWindowParams.format=PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations=0; ImageView v=new ImageView(getContext()); v.setBackgroundColor(dragndropBackgroundColor); v.setImageBitmap(bm); mDragBitmap=bm; mWindowManager=(WindowManager)getContext().getSystemService("window"); mWindowManager.addView(v,mWindowParams); mDragView=v; }
Example 49
@Override public void onFinishInflate(){ super.onFinishInflate(); this.setFocusable(true); final float DENSITY=this.getResources().getDisplayMetrics().density; mFrame=new FrameLayout(mContext); mFrame.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); int padding=(int)(DENSITY * 1 + 0.5f); mFrame.setPadding(0,padding,0,padding); mFrame.setBackgroundColor(R.color.black); mFrameForeground=new View(mContext); mFrameForeground.setBackgroundColor(this.getResources().getColor(R.color.genericBG)); mFrameForeground.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); mTeamText=new TextView(mContext); mTeamText.setText("No team assigned"); mTeamText.setLayoutParams(new LayoutParams((int)(DENSITY * INITIAL_TEXTWIDTH + 0.5f),LayoutParams.FILL_PARENT)); mTeamText.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); mTeamText.setIncludeFontPadding(false); mTeamText.setPadding((int)(DENSITY * 15 + 0.5f),0,0,0); mTeamText.setTextSize(TypedValue.COMPLEX_UNIT_DIP,INITIAL_TEXTSIZE); mFrame.addView(mFrameForeground); mFrame.addView(mTeamText); mButtons=new LinearLayout(mContext); mButtons.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); mButtons.setOrientation(LinearLayout.HORIZONTAL); mButtonAddTeam=new View(mContext); mButtonAddTeam.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1f)); mButtonAddTeam.setOnClickListener(mAddTeamListener); mButtonEditTeamName=new ImageButton(mContext); LinearLayout.LayoutParams buttonParams=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); buttonParams.gravity=(Gravity.CENTER_VERTICAL); buttonParams.rightMargin=(int)(DENSITY * 10 + 0.5f); mButtonEditTeamName.setLayoutParams(buttonParams); mButtonEditTeamName.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.gamesetup_editicon_selector)); mButtonEditTeamName.setOnClickListener(mEditTeamListener); mButtons.addView(mButtonAddTeam); mButtons.addView(mButtonEditTeamName); this.addView(mFrame); this.addView(mButtons); }
Example 50
From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/ui/dialogs/.
Source file: BrickCategoryDialog.java

public BrickCategoryDialog(ScriptTabActivity activity){ super(activity,R.style.brick_dialog); this.activity=activity; Window window=getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setGravity(Gravity.CENTER | Gravity.FILL_HORIZONTAL | Gravity.FILL_VERTICAL); setContentView(R.layout.dialog_categories); window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT); ImageButton closeButton=(ImageButton)findViewById(R.id.btn_close_dialog); closeButton.setOnClickListener(new View.OnClickListener(){ public void onClick( View v){ abort(); dismiss(); } } ); TextView textView=(TextView)findViewById(R.id.tv_dialog_title); textView.setText(activity.getString(R.string.categories)); }
Example 51
From project CheckIn4Me, under directory /src/com/davidivins/checkin4me/adapters/.
Source file: ServiceCheckListAdapter.java

/** * getView * @param position * @param convert_view * @param parent * @return View */ @Override public View getView(int position,View convert_view,ViewGroup parent){ View view=convert_view; ServiceInterface service=items.get(position); if (view == null) { LayoutInflater layout_inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view=layout_inflater.inflate(row_resource_id,null); } if (service != null) { LinearLayout icon_and_name_layout=(LinearLayout)view.findViewById(GeneratedResources.getId("service_icon_and_name")); LinearLayout check_box_layout=(LinearLayout)view.findViewById(GeneratedResources.getId("service_checkbox")); icon_and_name_layout.removeAllViews(); check_box_layout.removeAllViews(); ImageView icon=new ImageView(parent.getContext()); icon.setImageResource(service.getIconDrawable()); icon.setPadding(0,0,5,0); TextView name=new TextView(parent.getContext()); name.setText(service.getName()); name.setTextColor(Color.BLACK); name.setTextSize(20); CheckBox check_box=new CheckBox(parent.getContext()); boolean is_checked=false; if (service.getSettingsAsMap().containsKey(service.getName().toLowerCase() + "_check_in_default")) { is_checked=service.getSettingsAsMap().get(service.getName().toLowerCase() + "_check_in_default").getPrefValue(); check_box.setChecked(is_checked); } check_box.setId(service.getId()); services_checked.put(check_box.getId(),is_checked); check_box.setOnCheckedChangeListener(this); icon_and_name_layout.addView(icon); icon_and_name_layout.addView(name); check_box_layout.addView(check_box); name.setGravity(Gravity.CENTER_VERTICAL); icon_and_name_layout.setGravity(Gravity.CENTER_VERTICAL); check_box.setGravity(Gravity.CENTER_VERTICAL); check_box_layout.setGravity(Gravity.CENTER_VERTICAL); } return view; }
Example 52
From project CHMI, under directory /src/org/kaldax/app/chmi/.
Source file: StandardLayoutProviderLegacy.java

public void assembleLayoutPortrait(int iImageHeight,int iImageWidth){ layout.setVerticalGravity(Gravity.TOP); iv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); row2fr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE); layout.setGravity(android.view.Gravity.TOP | android.view.Gravity.LEFT); switch (imgHandler.getStaticFileMode()) { case ImagesHandlerImpl.STATIC_IMAGE_BACKGROUND: row2fr.addView(iv); break; case ImagesHandlerImpl.STATIC_IMAGE_FOREGROUND: row2fr.addView(iv); break; case ImagesHandlerImpl.STATIC_IMAGE_NONE: row2fr.addView(iv); break; default : } row2fr.addView(dateTextView); layout.addView(row2fr); row4.addView(imgProgressText); row4.setGravity(android.view.Gravity.CENTER); layout.addView(row4); row5.addView(statusText); row5.setGravity(android.view.Gravity.CENTER); layout.addView(row5); seekBar.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); seekBar.setPadding(5,5,5,20); row3.addView(btPlay); row3.addView(seekBar); row3.setVerticalGravity(Gravity.BOTTOM); row3.setHorizontalGravity(Gravity.CENTER_HORIZONTAL); row3.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.FILL_PARENT)); layout.addView(row3); row3.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.FILL_PARENT)); chmiActivity.setContentView(layout); }
Example 53
From project CineShowTime-Android, under directory /Libraries/GreenDroid/src/greendroid/widget/.
Source file: PageIndicator.java

private void initPageIndicator(){ mDotCount=MIN_DOT_COUNT; mGravity=Gravity.CENTER; mActiveDot=0; mDotSpacing=0; mDotType=DotType.SINGLE; mExtraState=onCreateDrawableState(1); mergeDrawableStates(mExtraState,SELECTED_STATE_SET); }
Example 54
From project CityBikes, under directory /src/net/homelinux/penecoptero/android/citybikes/app/.
Source file: InfoLayer.java

@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){ try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) { return false; } if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { vf.setInAnimation(inFromRightAnimation()); vf.setOutAnimation(outToLeftAnimation()); vf.showNext(); } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { vf.setInAnimation(inFromLeftAnimation()); vf.setOutAnimation(outToRightAnimation()); vf.showPrevious(); } if (onC2DMTour) { CityBikes.showCustomToast(ctx,self,ctx.getText(R.string.c2dm_tour_doing_great),Toast.LENGTH_LONG,Gravity.TOP | Gravity.CENTER_HORIZONTAL); } } catch ( Exception e) { } return false; }
Example 55
From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 56
From project cornerstone, under directory /frameworks/base/services/java/com/android/server/am/.
Source file: ActivityManagerService.java

public final void showSafeModeOverlay(){ View v=LayoutInflater.from(mContext).inflate(com.android.internal.R.layout.safe_mode,null); WindowManager.LayoutParams lp=new WindowManager.LayoutParams(); lp.type=WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; lp.width=WindowManager.LayoutParams.WRAP_CONTENT; lp.height=WindowManager.LayoutParams.WRAP_CONTENT; lp.gravity=Gravity.BOTTOM | Gravity.LEFT; lp.format=v.getBackground().getOpacity(); lp.flags=WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).addView(v,lp); }
Example 57
From project COSsettings, under directory /src/com/cyanogenmod/cmparts/activities/.
Source file: LightLevelsActivity.java

private TextView createTextView(int id,String text){ TextView tv=new TextView(this); tv.setGravity(Gravity.CENTER); tv.setText(text); tv.setWidth(dp2px(60)); tv.setId(id); return tv; }
Example 58
From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/view/menu/.
Source file: ActionMenuItemView.java

@Override public boolean onLongClick(View v){ if (hasText()) { return false; } final int[] screenPos=new int[2]; final Rect displayFrame=new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context=getContext(); final int width=getWidth(); final int height=getHeight(); final int midy=screenPos[1] + height / 2; final int screenWidth=context.getResources().getDisplayMetrics().widthPixels; Toast cheatSheet=Toast.makeText(context,mItemData.getTitle(),Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,screenWidth - screenPos[0] - width / 2,height); } else { cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,height); } cheatSheet.show(); return true; }
Example 59
From project creamed_glacier_app_settings, under directory /src/com/android/settings/.
Source file: AccessibilitySettings.java

private static ToggleSwitch createAndAddActionBarToggleSwitch(Activity activity){ ToggleSwitch toggleSwitch=new ToggleSwitch(activity); final int padding=activity.getResources().getDimensionPixelSize(R.dimen.action_bar_switch_padding); toggleSwitch.setPadding(0,0,padding,0); activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,ActionBar.DISPLAY_SHOW_CUSTOM); activity.getActionBar().setCustomView(toggleSwitch,new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,ActionBar.LayoutParams.WRAP_CONTENT,Gravity.CENTER_VERTICAL | Gravity.RIGHT)); return toggleSwitch; }