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:android.support.wear.widget.CircularProgressLayout.java
public CircularProgressLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mProgressDrawable = new CircularProgressDrawable(context); mProgressDrawable.setProgressRotation(DEFAULT_ROTATION); mProgressDrawable.setStrokeCap(Paint.Cap.BUTT); setBackground(mProgressDrawable);// w w w .j a v a2 s. co m // If a child view is added, make it center aligned so it fits in the progress drawable. setOnHierarchyChangeListener(new OnHierarchyChangeListener() { @Override public void onChildViewAdded(View parent, View child) { // Ensure that child view is aligned in center LayoutParams params = (LayoutParams) child.getLayoutParams(); params.gravity = Gravity.CENTER; child.setLayoutParams(params); } @Override public void onChildViewRemoved(View parent, View child) { } }); mController = new CircularProgressLayoutController(this); Resources r = context.getResources(); TypedArray a = r.obtainAttributes(attrs, R.styleable.CircularProgressLayout); if (a.getType(R.styleable.CircularProgressLayout_colorSchemeColors) == TypedValue.TYPE_REFERENCE || !a.hasValue(R.styleable.CircularProgressLayout_colorSchemeColors)) { int arrayResId = a.getResourceId(R.styleable.CircularProgressLayout_colorSchemeColors, R.array.circular_progress_layout_color_scheme_colors); setColorSchemeColors(getColorListFromResources(r, arrayResId)); } else { setColorSchemeColors(a.getColor(R.styleable.CircularProgressLayout_colorSchemeColors, Color.BLACK)); } setStrokeWidth(a.getDimensionPixelSize(R.styleable.CircularProgressLayout_strokeWidth, r.getDimensionPixelSize(R.dimen.circular_progress_layout_stroke_width))); setBackgroundColor(a.getColor(R.styleable.CircularProgressLayout_backgroundColor, ContextCompat.getColor(context, R.color.circular_progress_layout_background_color))); setIndeterminate(a.getBoolean(R.styleable.CircularProgressLayout_indeterminate, false)); a.recycle(); }
From source file:android.view.SpringIndicator.java
private void addTabContainerView() { tabContainer = new LinearLayout(getContext()); tabContainer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f)); tabContainer.setOrientation(LinearLayout.HORIZONTAL); tabContainer.setGravity(Gravity.CENTER); addView(tabContainer);//from w ww . j a v a 2s.c o m }
From source file:cn.org.eshow.framwork.view.sliding.AbBottomTabView.java
/** * Instantiates a new ab bottom tab view. * * @param context the context/* ww w . j a v a2 s. c o m*/ * @param attrs the attrs */ public AbBottomTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //View? mViewPager = new AbViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); //? mTabImg = new ImageView(context); mTabImg.setBackgroundColor(tabSlidingColor); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); this.addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Tab? tabItemList = new ArrayList<AbTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbBottomTabView.class, "AbSlidingTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:com.bangqu.eshow.view.sliding.ESBottomTabView.java
/** * Instantiates a new ab bottom tab view. * * @param context the context/* w w w . java 2 s. c o m*/ * @param attrs the attrs */ public ESBottomTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //View? mViewPager = new ESViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); //? mTabImg = new ImageView(context); mTabImg.setBackgroundColor(tabSlidingColor); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); this.addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Tab? tabItemList = new ArrayList<ESTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { ESLogUtil.e(ESBottomTabView.class, "AbSlidingTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = ESAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:com.morphoss.jumble.frontend.CategoryScreenActivity.java
/** * This method creates a popup window when a level is unlocked *///from w w w. j av a 2s . c o m public void PopupWindowLevel() { try { LayoutInflater inflater = (LayoutInflater) CategoryScreenActivity.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_level, (ViewGroup) findViewById(R.id.popup_element)); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); pwindowLevel = new PopupWindow(layout, metrics.widthPixels, metrics.heightPixels, true); pwindowLevel.showAtLocation(layout, Gravity.CENTER, 0, 0); btnClosePopupLevel = (ImageView) layout.findViewById(R.id.btn_close_popup); btnClosePopupLevel.setOnClickListener(cancel_popup_level); } catch (Exception e) { e.printStackTrace(); } }
From source file:foam.jellyfish.StarwispBuilder.java
public int BuildLayoutGravity(String p) { if (p.equals("centre")) return Gravity.CENTER; if (p.equals("left")) return Gravity.LEFT; if (p.equals("right")) return Gravity.RIGHT; if (p.equals("fill")) return Gravity.FILL; return Gravity.LEFT; }
From source file:com.app.sample.chatting.activity.chat.FacePageFragment.java
@Override protected void initWidget(View rootView) { super.initWidget(rootView); mPagerFace = (ViewPager) rootView.findViewById(R.id.frag_pager_face); pagePointLayout = (LinearLayout) rootView.findViewById(R.id.frag_point); int total = datas.size(); int pages = total / ITEM_PAGE_COUNT + (total % ITEM_PAGE_COUNT == 0 ? 0 : 1); allPageViews = new GridView[pages]; pointViews = new RadioButton[pages]; for (int x = 0; x < pages; x++) { int start = x * ITEM_PAGE_COUNT; int end = (start + ITEM_PAGE_COUNT) > total ? total : (start + ITEM_PAGE_COUNT); final List<Faceicon> itemDatas = datas.subList(start, end); GridView view = new GridView(aty); FaceAdapter faceAdapter = new FaceAdapter(view, itemDatas); view.setAdapter(faceAdapter);// w ww.ja v a 2 s .c o m view.setNumColumns(4); view.setBackgroundColor(Color.TRANSPARENT); view.setHorizontalSpacing(1); view.setVerticalSpacing(1); view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); view.setCacheColorHint(0); view.setVerticalScrollBarEnabled(false); view.setPadding(5, 0, 5, 0); view.setSelector(new ColorDrawable(Color.TRANSPARENT)); view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); view.setGravity(Gravity.CENTER); view.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (listener != null) { listener.selectedFace(itemDatas.get(position)); } } }); allPageViews[x] = view; RadioButton tip = new RadioButton(aty); tip.setBackgroundResource(R.drawable.selector_bg_tip); RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(8, 8); layoutParams.leftMargin = 10; pagePointLayout.addView(tip, layoutParams); if (x == 0) { tip.setChecked(true); } pointViews[x] = tip; } PagerAdapter facePagerAdapter = new FacePagerAdapter(allPageViews); mPagerFace.setAdapter(facePagerAdapter); mPagerFace.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int index) { pointViews[index].setChecked(true); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); }
From source file:com.insthub.O2OMobile.Activity.C4_EditIntroActivity.java
@Override public void OnMessageResponse(String url, JSONObject jo, AjaxStatus status) throws JSONException { if (url.endsWith(ApiInterface.USER_CHANGE_PROFILE)) { ToastView toast = new ToastView(C4_EditIntroActivity.this, getString(R.string.brief_edit_success)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();/*w w w . j a v a2 s. co m*/ finish(); } }
From source file:com.firesoft.member.Activity.B0_SigninActivity.java
public void ToastShow(String atr) { ToastView toast = new ToastView(this, atr); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:com.ab.view.sliding.AbBottomTabView_fix.java
/** * Instantiates a new ab bottom tab view. * * @param context the context/*from ww w. j a v a 2s . com*/ * @param attrs the attrs */ public AbBottomTabView_fix(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //View? mViewPager = new AbViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); //? mTabImg = new ImageView(context); mTabImg.setBackgroundColor(tabSlidingColor); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); this.addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Tab? tabItemList = new ArrayList<AbTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbBottomTabView_fix.class, "AbSlidingTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerStateAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }