List of usage examples for android.widget TextView setGravity
public void setGravity(int gravity)
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LocationObj.java
@Override public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/* w w w . ja v a 2s. co m*/ TextView valueTV = new TextView(context); NumberFormat df = DecimalFormat.getNumberInstance(); df.setMaximumFractionDigits(5); df.setMinimumFractionDigits(5); String msg = "I'm at " + df.format(content.optDouble(COORD_LAT)) + ", " + df.format(content.optDouble(COORD_LONG)); valueTV.setText(msg); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); }
From source file:com.geeya.wifitv.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from ww w . jav a 2 s.co m*/ tab.setGravity(Gravity.CENTER); //tab.setSingleLine(); addTab(position, tab); }
From source file:com.gc.materialdesign.views.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from ww w.j ava 2s . co m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); // tab.setBackgroundResource(R.drawable.tab_selector); addTab(position, tab); }
From source file:cn.bingoogol.tabhost.ui.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from ww w . ja v a 2 s . c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.metinkale.prayerapp.utils.PagerSlidingTabStrip.java
private void addTextTab(int position, CharSequence title) { TextView tab = new TextView(getContext()); tab.setText(title);//www . ja v a2 s . c o m tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.huyn.demogroup.relativetop.PagerSlidingTabStrip.java
private void addIconAndTextTab(int position, int resId, String title) { LinearLayout tab = new LinearLayout(getContext()); tab.setGravity(Gravity.CENTER);/*from w ww . jav a 2 s . co m*/ TextView text = new TextView(getContext()); text.setText(title); text.setTextColor(Color.WHITE); text.setGravity(Gravity.CENTER); text.setSingleLine(); ImageView img = new ImageView(getContext()); img.setImageBitmap(iProvider.getBitmap(resId)); tab.addView(img); tab.addView(text); text.setPadding(10, 0, 0, 0); text.setTag("TEXT"); addTab(position, tab); }
From source file:com.chenl.widgets.flippablestackview.indicator.OrientedPagerSlidingTabLayout.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//w ww.j a v a 2 s. c o m tab.setGravity(Gravity.CENTER); tab.setMaxLines(2); addTab(position, tab); }
From source file:com.mci.firstidol.view.ActionSheet.java
@SuppressWarnings("deprecation") private View createView() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getActivity()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.argb(136, 0, 0, 0)); mBg.setId(ActionSheet.BG_VIEW_ID);/*from w ww . ja v a2s . co m*/ mBg.setOnClickListener(this); mPanel = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); TextView titleView = new TextView(getActivity()); titleView.setText(TextUtils.isEmpty(getTitle()) ? "" : getTitle()); titleView.setGravity(Gravity.CENTER); titleView.setTextColor(Color.GRAY); titleView.setBackgroundDrawable(mAttrs.actionSheetTitleBackground); mPanel.addView(titleView); parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java
@Override public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { PackageManager pm = context.getPackageManager(); Drawable icon = null;//from w ww .java2 s . c o m String appName; if (obj.getJson() != null && obj.getJson().has(ANDROID_PACKAGE_NAME)) { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); } else { appName = "Unknown"; } if (!(obj instanceof DbObj)) { if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Preparing application " + appName + "..."; // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); return; } DbObj dbParentObj = (DbObj) obj; boolean rendered = false; Intent launch = getLaunchIntent(context, dbParentObj); List<ResolveInfo> infos = pm.queryIntentActivities(launch, 0); if (infos.size() > 0) { ResolveInfo info = infos.get(0); if (info.activityInfo.labelRes != 0) { appName = info.activityInfo.loadLabel(pm).toString(); icon = info.loadIcon(pm); } else { appName = info.activityInfo.name; } } else { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } } // TODO: Safer reference to containing view if (icon != null) { View parentView = (View) frame.getParent().getParent(); ImageView avatar = (ImageView) parentView.findViewById(R.id.icon); avatar.setImageDrawable(icon); TextView label = (TextView) parentView.findViewById(R.id.name_text); label.setText(appName); } // TODO: obj.getLatestChild().render(); String selection = getRenderableClause(); String[] selectionArgs = null; Cursor cursor = dbParentObj.getSubfeed().query(selection, selectionArgs); if (cursor.moveToFirst()) { DbObj dbObj = App.instance().getMusubi().objForCursor(cursor); DbObjects.getFeedRenderer(dbObj.getType()).render(context, frame, dbObj, allowInteractions); rendered = true; } if (!rendered) { String text; if (icon != null) { ImageView iv = new ImageView(context); iv.setImageDrawable(icon); iv.setAdjustViewBounds(true); iv.setMaxWidth(60); iv.setMaxHeight(60); iv.setLayoutParams(CommonLayouts.WRAPPED); frame.addView(iv); text = appName; } else { text = "New application: " + appName + "."; } // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }
From source file:com.andreapivetta.blu.fragments.tabs.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 . j a va 2s. com*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 2); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); textView.setTextColor(getResources().getColor(com.andreapivetta.blu.R.color.white)); return textView; }