List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java
/** * Instantiates a new ab sliding smooth tab view. * * @param context the context/*from ww w . j a va 2 s. c o m*/ * @param attrs the attrs */ public AbSlidingSmoothTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabScrollView = new AbHorizontalScrollView(context); mTabScrollView.setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //mTabLayout mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT)); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabScrollView, layoutParamsFW); //? mTabImg = new ImageView(context); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, layoutParamsFF); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbSlidingSmoothTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); mTabScrollView.setSmoothScrollingEnabled(true); mTabScrollView.setOnScrollListener(new AbOnScrollListener() { @Override public void onScrollToRight() { AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToRight"); } @Override public void onScrollToLeft() { AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToLeft"); } @Override public void onScrollStoped() { AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollStoped"); } @Override public void onScroll(int arg1) { scrollX = arg1; View view = mTabLayout.getChildAt(mSelectedTabIndex); int toX = view.getLeft() - scrollX; AbLogUtil.d(AbSlidingSmoothTabView.class, "X" + startX + "to" + toX); imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } }); }
From source file:com.astuetz.PagerSlidingTabStripMenu.java
public PagerSlidingTabStripMenu(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // setFillViewport(true); setWillNotDraw(false);/* w ww .j a v a 2 s . co m*/ tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); tabsContainer.setGravity(Gravity.CENTER); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); mTabPaddingTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mTabPaddingTop, dm); mTabPaddingBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mTabPaddingBottom, dm); mTabDrawablePadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mTabDrawablePadding, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(0, tabTextSize); tabTextColor = a.getColor(1, tabTextColor); a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); mIconPostion = IconPosition .fromValue(a.getInteger(R.styleable.PagerSlidingTabStrip_pstsIconPosition, mIconPostion.value)); mTabPaddingTop = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStrip_pstsTabPaddingTop, mTabPaddingTop); mTabPaddingBottom = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStrip_pstsTabPaddingBottom, mTabPaddingBottom); mTabDrawablePadding = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStrip_pstsTabDrawablePadding, mTabDrawablePadding); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:fr.univsavoie.ltp.client.map.Popup.java
/** * Afficher sur la map un popup qui affiche les * informations de l'utilisateur connect. *//*from ww w . j a v a2 s . c o m*/ public final void popupDisplayUserInfos() { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; int popupWidth = (int) (width * 0.75); //int popupHeight = height / 2; // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupAccount); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_account, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupUserInfos = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupUserInfos.setBackgroundDrawable(new BitmapDrawable()); popupUserInfos.setOutsideTouchable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. final int OFFSET_X = 0; final int OFFSET_Y = 0; // Displaying the popup at the specified location, + offsets. this.activity.findViewById(R.id.layoutMain).post(new Runnable() { public void run() { popupUserInfos.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); } }); /* * Evenements composants du PopupWindow */ // Ecouteur d'vnement sur le bouton pour se dconnecter Button close = (Button) layout.findViewById(R.id.close); close.setOnClickListener(new OnClickListener() { public void onClick(View v) { popupUserInfos.dismiss(); } }); }
From source file:edu.cnu.PowerTutor.ui.PowerViewer.java
public void refreshView() { if (counterService == null) { TextView loadingText = new TextView(this); loadingText.setText("Waiting for profiler service..."); loadingText.setGravity(Gravity.CENTER); setContentView(loadingText);// w w w .ja v a 2 s .co m return; } chartLayout = new LinearLayout(this); chartLayout.setOrientation(LinearLayout.VERTICAL); if (uid == SystemInfo.AID_ALL) { /* * If we are reporting global power usage then just set noUidMask to * 0 so that all components get displayed. */ noUidMask = 0; } components = 0; for (int i = 0; i < componentNames.length; i++) { if ((noUidMask & 1 << i) == 0) { components++; } } boolean showTotal = prefs.getBoolean("showTotalPower", false); collectors = new ValueCollector[(showTotal ? 1 : 0) + components]; int pos = 0; for (int i = showTotal ? -1 : 0; i < componentNames.length; i++) { if (i != -1 && (noUidMask & 1 << i) != 0) { continue; } String name = i == -1 ? "Total" : componentNames[i]; double mxPower = (i == -1 ? 2100.0 : componentsMaxPower[i]) * 1.05; XYSeries series = new XYSeries(name); XYMultipleSeriesDataset mseries = new XYMultipleSeriesDataset(); mseries.addSeries(series); XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); XYSeriesRenderer srenderer = new XYSeriesRenderer(); renderer.setYAxisMin(0.0); renderer.setYAxisMax(mxPower); renderer.setYTitle(name + "(mW)"); int clr = PowerPie.COLORS[(PowerPie.COLORS.length + i) % PowerPie.COLORS.length]; srenderer.setColor(clr); srenderer.setFillBelowLine(true); srenderer.setFillBelowLineColor(((clr >> 1) & 0x7F7F7F) | (clr & 0xFF000000)); renderer.addSeriesRenderer(srenderer); View chartView = new GraphicalView(this, new CubicLineChart(mseries, renderer, 0.5f)); chartView.setMinimumHeight(100); chartLayout.addView(chartView); collectors[pos] = new ValueCollector(series, renderer, chartView, i); if (handler != null) { // Main Handler? . (debug) handler.post(collectors[pos]); } pos++; } /* * We're giving 100 pixels per graph of vertical space for the chart * view. If we don't specify a minimum height the chart view ends up * having a height of 0 so this is important. */ chartLayout.setMinimumHeight(100 * components); ScrollView scrollView = new ScrollView(this); scrollView.addView(chartLayout); setContentView(scrollView); }
From source file:ab.util.AbDialogUtil.java
/** * ?() * * @param view */ public static AbSampleDialogFragment showDialog(View view) { return showDialog(view, Gravity.CENTER); }
From source file:at.wada811.app.fragment.ExpandableListFragment.java
/** * Provide default implementation to return a expandable list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ExpandableListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when * the list is empty.//from w ww.j ava 2 s . c o m * * <p> * If you are overriding this method with your own custom content, consider including the * standard layout {@link android.R.layout#list_content} in your layout file, so that you * continue to retain all of the standard behavior of ExpandableListFragment. In particular, * this is currently the only way to have the built-in indeterminant progress state be shown. * * @param inflater The LayoutInflater object that can be used to inflate any views in the * fragment, * @param container If non-null, this is the parent view that the fragment's UI should be * attached to. The fragment should not add the view itself, but this can be used to * generate the LayoutParams of the view. * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous * saved state as given here. * @return Return the View for the fragment's UI, or null. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, 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)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, 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)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.android.design.material.widgets.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w. ja va2 s. com */ protected TextView createDefaultTabView(Context context) { final TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabTextViewSize); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); final TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); final int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.antonioleiva.materialeverywhere.HomeActivity1.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarIcon(R.drawable.ic_ab_drawer); GridView gridView = (GridView) findViewById(R.id.gridView); gridView.setAdapter(new GridViewAdapter()); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w . ja v a2 s . c o m public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String url = (String) view.getTag(); DetailActivity.launch(HomeActivity1.this, view.findViewById(R.id.image), url); } }); drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); NotificationManager notifier = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifier.cancel(ACTION_NOTIFICATION_ID); //? ?? Intent intent1 = new Intent(this, HomeActivity1.class); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, ACTION_NOTIFICATION_ID, intent1, 0); NotificationCompat.WearableExtender secondWearableExtender = new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.ic_launcher).setContentIconGravity(Gravity.CENTER); //step4 Notification secondPage = new NotificationCompat.Builder(this).setContentTitle("Step 4") .setContentText(" ? ? ? ?.") .extend(secondWearableExtender).build(); //5 NotificationCompat.Action step5 = new NotificationCompat.Action(R.drawable.ic_launcher, "step5", viewPendingIntent); //step5 Notification thirdPage = new NotificationCompat.Builder(this).setContentTitle("Step 5") .setContentText(" .") .extend(new NotificationCompat.WearableExtender().setContentIcon(R.drawable.ic_launcher) .setContentIconGravity(Gravity.CENTER).setContentAction(0)) .build(); //step6 Notification fourthPage = new NotificationCompat.Builder(this).setContentTitle("Step 6") .setContentText(" ? .") .extend(new NotificationCompat.WearableExtender().setContentIcon(R.drawable.ic_launcher) .setContentIconGravity(Gravity.CENTER)) .build(); // ?? ? ?. //?, ? NotificationCompat.WearableExtender wearableOptions = new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.ic_launcher).setContentIconGravity(Gravity.CENTER).addAction(step5) .addPage(secondPage).addPage(thirdPage).addPage(fourthPage); // ? ? ? Notification notification = new NotificationCompat.Builder(this).setContentTitle("?") .setContentText("2").setUsesChronometer(true).setSmallIcon(R.drawable.ic_launcher) .extend(wearableOptions).setAutoCancel(true).build(); //? // ? ? . NotificationManagerCompat.from(this).notify(RECIPE_NOTIFICATION_ID, notification); }
From source file:com.insthub.O2OMobile.Activity.C3_EditNameActivity.java
@Override public void onClick(View v) { String nickname = mNickname.getText().toString().trim(); switch (v.getId()) { case R.id.top_view_back: finish();/*from www .ja va 2 s.c o m*/ break; case R.id.btn_save: if ("".equals(nickname)) { ToastView toast = new ToastView(C3_EditNameActivity.this, getString(R.string.please_input_nickname)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mNickname.setText(""); mNickname.requestFocus(); break; } else if (nickname.length() < 1 || nickname.length() > 16) { ToastView toast = new ToastView(C3_EditNameActivity.this, getString(R.string.nickname_wrong_format_hint)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mNickname.requestFocus(); } else { mUserModel.changeNickname(nickname); } } }
From source file:com.insthub.O2OMobile.Activity.C13_EditPasswordActivity.java
@Override public void onClick(View v) { String now_password = mNowPassword.getText().toString().trim(); String new_password = mNewPassword.getText().toString().trim(); String re_new_password = mReNewPassword.getText().toString().trim(); switch (v.getId()) { case R.id.top_view_back: finish();/* w w w .j a v a 2s . c o m*/ break; case R.id.save: if ("".equals(now_password)) { ToastView toast = new ToastView(C13_EditPasswordActivity.this, getString(R.string.input_password)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mNowPassword.requestFocus(); mNowPassword.setText(""); } else if (now_password.length() < 6 || now_password.length() > 20) { ToastView toast = new ToastView(C13_EditPasswordActivity.this, getString(R.string.password_wrong_format_hint)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mNowPassword.requestFocus(); } else if ("".equals(new_password)) { ToastView toast = new ToastView(C13_EditPasswordActivity.this, getString(R.string.input_new_password)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mNewPassword.requestFocus(); mNewPassword.setText(""); } else if (new_password.length() < 6 || new_password.length() > 20) { ToastView toast = new ToastView(C13_EditPasswordActivity.this, getString(R.string.new_password_wrong_format_hint)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mNewPassword.requestFocus(); } else if (!new_password.equals(re_new_password)) { ToastView toast = new ToastView(C13_EditPasswordActivity.this, getString(R.string.two_passwords_differ_hint)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); mReNewPassword.requestFocus(); } else { mUserModel.changePassword(now_password, new_password); } break; } }