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:app.dropbox.encryption.encryptionsetup.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.encryption_setup); initilizingVariables();//from w ww . ja v a 2 s . com if (encryptKey != null) { if (fileToEncrypt != null) launchEncryption(); else launchnext(); } else { // acctok=getSharedPreferences("accesstoken",0); // accessToken =acctok.getString("accesstoken", null); // if(accessToken==null){ // goback(); // } // final EditText key = (EditText) findViewById(R.id.editText1); ImageButton encrypt = (ImageButton) findViewById(R.id.imageButton1); encrypt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { encryptKey = key.getText().toString(); if (keyValidator(encryptKey)) { key.setText(""); setKeyToPreferences(); if (fileToEncrypt != null) launchEncryption(); else launchnext(); } else { Toast toast = Toast.makeText(encryptionsetup.this, "Enter key between 5 to 16 Characters", 2000); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } } }); } }
From source file:com.acrylicgoat.houstonbicyclemuseum.view.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }//from ww w. j av a2s .co m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.appnexus.opensdk.mediatedviews.RubiconBannerAdView.java
@Override public View requestAd(MediatedBannerAdViewController mBC, Activity activity, String parameter, String uid, int width, int height, TargetingParameters targetingParameters) { String adId = null;/*from w w w. j av a2 s. c o m*/ String serverName = null; String pubId = null; try { if (!StringUtil.isEmpty(uid)) { JSONObject idObject = new JSONObject(uid); adId = idObject.getString(AD_ID); serverName = idObject.getString(SERVER_NAME); pubId = idObject.getString(PUB_ID); } else { mBC.onAdFailed(ResultCode.INVALID_REQUEST); return null; } } catch (JSONException e) { mBC.onAdFailed(ResultCode.INVALID_REQUEST); return null; } RFMAdViewListener adViewListener = new RubiconListener(mBC, this.getClass().getSimpleName()); RFMAdRequest rfmAdRequest = new RFMAdRequest(); rfmAdRequest.setRFMParams(serverName, pubId, adId); rfmAdRequest.setAdDimensionParams(width, height); adView = new RFMAdView(activity); adView.setRFMAdViewListener(adViewListener); adView.enableHWAcceleration(true); if (targetingParameters != null) { if (targetingParameters.getLocation() != null) { rfmAdRequest.setLocation(targetingParameters.getLocation()); } //Optional Ad Targeting info rfmAdRequest.setTargetingParams(getTargetingParams(targetingParameters)); } adView.setMinimumWidth(width); adView.setMinimumHeight(height); adView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); adView.requestRFMAd(rfmAdRequest); return adView; }
From source file:com.ashlikun.badgeview.BadgeView.java
private void init(AttributeSet attrs) { defaultHeight = dip2px(getContext(), defaultHeight); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BadgeView); // set default background setBackground(dip2px(getContext(), radius), a.getColor(R.styleable.BadgeView_bvColor, bvColor)); mHideOnNull = a.getBoolean(R.styleable.BadgeView_bvISHideNull, true); a.recycle();//from w w w . java2s. com setGravity(Gravity.CENTER); setPadding((int) (radius / 3f), 0, (int) (radius / 3f), 0); ViewCompat.setElevation(this, dip2px(getContext(), 1)); setTypeface(null, Typeface.BOLD); }
From source file:com.gotraveling.insthub.BeeFramework.model.BaseModel.java
public void callback(String url, JSONObject jo, AjaxStatus status) { if (null == jo) { ToastView toast = new ToastView(mContext, ""); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();/*from w ww . java 2 s.co m*/ return; } try { STATUS responseStatus = new STATUS(); responseStatus.fromJson(jo.optJSONObject("status")); if (responseStatus.succeed != ErrorCodeConst.ResponseSucceed) { if (responseStatus.error_code == ErrorCodeConst.InvalidSession) { ToastView toast = new ToastView(mContext, mContext.getString(R.string.session_expires_tips)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); E0_ProfileFragment.isRefresh = true; Intent intent = new Intent(mContext, A0_SigninActivity.class); mContext.startActivity(intent); shared = mContext.getSharedPreferences("userInfo", 0); editor = shared.edit(); editor.putString("uid", ""); editor.putString("sid", ""); editor.commit(); SESSION.getInstance().uid = shared.getString("uid", ""); SESSION.getInstance().sid = shared.getString("sid", ""); } } Resources resource = mContext.getResources(); String way = resource.getString(R.string.delivery); String col = resource.getString(R.string.collected); String und = resource.getString(R.string.understock); String been = resource.getString(R.string.been_used); String sub = resource.getString(R.string.submit_the_parameter_error); String fai = resource.getString(R.string.failed); String pur = resource.getString(R.string.error_10008); String noi = resource.getString(R.string.no_shipping_information); String error = resource.getString(R.string.username_or_password_error); if (responseStatus.error_code == ErrorCodeConst.SelectedDeliverMethod) { ToastView toast = new ToastView(mContext, way); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.AlreadyCollected) { //Toast.makeText(mContext, "??", Toast.LENGTH_SHORT).show(); ToastView toast = new ToastView(mContext, col); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.InventoryShortage) { ToastView toast = new ToastView(mContext, und); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.UserOrEmailExist) { ToastView toast = new ToastView(mContext, been); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.InvalidParameter) { ToastView toast = new ToastView(mContext, sub); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.ProcessFailed) { ToastView toast = new ToastView(mContext, fai); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.BuyFailed) { ToastView toast = new ToastView(mContext, pur); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.NoShippingInformation) { ToastView toast = new ToastView(mContext, noi); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.InvalidUsernameOrPassword) { ToastView toast = new ToastView(mContext, error); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } if (responseStatus.error_code == ErrorCodeConst.UserOrEmailExist) { ToastView toast = new ToastView(mContext, resource.getString(R.string.been_used)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } } catch (JSONException e) { } }
From source file:ca.appvelopers.mcgillmobile.ui.walkthrough.WalkthroughAdapter.java
@Override public Object instantiateItem(ViewGroup collection, int position) { final Context context = collection.getContext(); View view;//from w w w . j a v a 2 s . co m switch (position) { //Welcome case 0: view = View.inflate(context, R.layout.item_walkthrough_0, null); break; //Access Essentials case 1: view = View.inflate(context, R.layout.item_walkthrough_1, null); break; //Main Menu Explanation case 2: view = View.inflate(context, R.layout.item_walkthrough_2, null); break; // //Horizontal Schedule // case 3: // view = View.inflate(context, R.layout.item_walkthrough_3, null); // break; //Info case 3: view = View.inflate(context, R.layout.item_walkthrough_4, null); break; //Default HomepageManager / Faculty (first open only) case 4: view = View.inflate(context, R.layout.item_walkthrough_5, null); FormGenerator fg = FormGenerator.bind(context, (LinearLayout) view); //HomepageManager Prompt fg.text(R.string.walkthrough_homepage).gravity(Gravity.CENTER) .padding(context.getResources().getDimensionPixelOffset(R.dimen.padding_small)).build(); //HomepageManager fg.text(homepagePref.getTitleString()).leftIcon(R.drawable.ic_phone_android) .rightIcon(R.drawable.ic_chevron_right, Color.GRAY) .onClick(new TextViewFormItem.OnClickListener() { @Override public void onClick(final TextViewFormItem item) { DialogUtils.list(context, R.string.settings_homepage_title, new HomepageListAdapter(context) { @Override public void onHomepageSelected(@HomepageManager.Homepage int choice) { //Update it homepageManager.set(choice); item.view().setText(homepageManager.getTitleString()); analytics.sendEvent("Walkthrough", "HomepageManager", homepageManager.getString()); } }); } }).build(); //Faculty Prompt fg.text(R.string.walkthrough_faculty).gravity(Gravity.CENTER) .padding(context.getResources().getDimensionPixelOffset(R.dimen.padding_small)).build(); //Faculty fg.text(R.string.faculty_none).leftIcon(R.drawable.ic_mycourses) .rightIcon(R.drawable.ic_chevron_right, Color.GRAY) .onClick(new TextViewFormItem.OnClickListener() { @Override public void onClick(final TextViewFormItem item) { DialogUtils.list(context, R.string.faculty_title, new FacultyListAdapter(context, item.view().getText().toString()) { @Override public void onFacultySelected(String faculty) { //Update the view item.view().setText(faculty); //If the faculty is not empty, send the GA analytics.sendEvent("Walkthrough", "Faculty", faculty); } }); } }).build(); break; default: throw new IllegalStateException("Unknown position " + position + " in walkthrough"); } collection.addView(view); return view; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/* w ww.ja v a2s . co m*/ LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setText(asText(content)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0); container.addView(imageView); container.addView(valueTV); frame.addView(container); }
From source file:br.unb.mobileMedia.core.view.ExpandableListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView 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. * <p/>/*from w w w . j a v a2 s .c om*/ * <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 ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout root = new FrameLayout(getActivity()); FrameLayout lframe = new FrameLayout(getActivity()); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); root.setLayoutParams(lp); return root; }
From source file:com.axum.darivb.searchview.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(bariol_regular_tf); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }/*from w ww. ja va2 s . c om*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.app.sample.chatting.data.emoji.EmojiPageFragment.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<Emojicon> itemDatas = datas.subList(start, end); GridView view = new GridView(aty); EmojiAdapter faceAdapter = new EmojiAdapter(view, itemDatas); view.setNumColumns(7);/*from w ww . java 2s . c o m*/ view.setHorizontalSpacing(1); view.setVerticalSpacing(1); view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); view.setCacheColorHint(0); view.setPadding(2, 0, 2, 0); view.setBackgroundResource(android.R.color.transparent); view.setSelector(android.R.color.transparent); view.setVerticalScrollBarEnabled(false); view.setGravity(Gravity.CENTER); view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); view.setAdapter(faceAdapter); view.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (listener != null) { Emojicon emoji = itemDatas.get(position); if (DisplayRules.isDeleteEmojicon(emoji)) { listener.selectedBackSpace(emoji); } else { listener.selectedEmoji(emoji); } } } }); 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 ViewPager.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) { } }); }