List of usage examples for android.widget TextView setPadding
@Override public void setPadding(int left, int top, int right, int bottom)
From source file:com.example.appdetail_optimization.PagerSlidingTabStrip.java
@SuppressWarnings("deprecation") private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w . ja v a2s . c om*/ tab.setGravity(Gravity.CENTER); tab.setPadding(0, 0, 0, 0); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); tab.setMaxWidth(width / tabCount - tabPadding * 2); tab.setEllipsize(TruncateAt.END); tab.setSingleLine(); addTab(position, tab); }
From source file:com.zxly.o2o.view.MPagerSlidingTab.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setPadding(DesityUtil.dp2px(getContext(), 6), 0, DesityUtil.dp2px(getContext(), 6), 0); tab.setText(title);/*from w w w.j ava 2s .c o m*/ tab.setSingleLine(); tab.setTextColor(tabTextColor); tab.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final SRThemeAttributes attr = new SRThemeAttributes(context); mPost = post;/* w w w .ja va2s .c om*/ isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, SRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:de.gebatzens.ggvertretungsplan.fragment.RemoteDataFragment.java
public void createButtonWithText(Activity activity, ViewGroup l, String text, String button, View.OnClickListener onclick) { RelativeLayout r = new RelativeLayout(activity); r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TextView tv = new TextView(activity); RelativeLayout.LayoutParams tvparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); tvparams.addRule(RelativeLayout.ABOVE, R.id.reload_button); tvparams.addRule(RelativeLayout.CENTER_HORIZONTAL); tv.setLayoutParams(tvparams);//w w w . j a v a 2 s . c om tv.setText(text); tv.setTextSize(23); tv.setPadding(0, 0, 0, toPixels(15)); tv.setGravity(Gravity.CENTER_HORIZONTAL); r.addView(tv); Button b = new Button(activity); RelativeLayout.LayoutParams bparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); bparams.addRule(RelativeLayout.CENTER_VERTICAL); bparams.addRule(RelativeLayout.CENTER_HORIZONTAL); b.setLayoutParams(bparams); b.setId(R.id.reload_button); b.setText(button); b.setTextSize(23); b.setAllCaps(false); b.setTypeface(null, Typeface.NORMAL); b.setOnClickListener(onclick); r.addView(b); l.addView(r); }
From source file:com.jaspersoft.android.jaspermobile.widget.DraggableViewsContainer.java
private void showTextInputDialog(int viewId) { final AnnotationInputDialog annotationInputDialog = new AnnotationInputDialog(getContext()); annotationInputDialog.setTitle(getContext().getString(R.string.annotation_add_note)); annotationInputDialog.setId(viewId); annotationInputDialog.setValue(""); annotationInputDialog.setOnEventListener(new AnnotationInputDialog.OnAnnotationInputListener() { @Override/*w w w. j a v a2 s . c om*/ public void onAnnotationEntered(int id, String inputText) { TextView note = (TextView) findViewById(id); note.setText(inputText); if (mNeedsBorder) { note.setBackgroundResource(R.drawable.bg_annotation_text_border); note.getBackground().setColorFilter(mColor, PorterDuff.Mode.MULTIPLY); int borderPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, BORDER_PADDING, getContext().getResources().getDisplayMetrics()); note.setPadding(borderPadding, borderPadding, borderPadding, borderPadding); } analytics.sendEvent(Analytics.EventCategory.RESOURCE.getValue(), Analytics.EventAction.ANNOTATED.getValue(), Analytics.EventLabel.WITH_TEXT.getValue()); } @Override public void onAnnotationCanceled(int id) { TextView noteView = (TextView) findViewById(id); removeView(noteView); } }); annotationInputDialog.show(); }
From source file:com.joravasal.comicagg.ComicDetailFragment.java
@SuppressLint({ "NewApi" }) @Override//from w w w .ja v a2 s .co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_comic_detail, container, false); if (comicItem == null && savedInstanceState.containsKey(ARG_ITEM_ID)) { comicItem = new ComicItem(savedInstanceState.getString(ARG_ITEM_ID), savedInstanceState.getString("comicname"), savedInstanceState.getString("comicurl"), savedInstanceState.getString("unreadcount")); } int unread = Integer.parseInt(comicItem.unreadCount); if (unread == 0) { rootView.findViewById(R.id.vote_bar).setVisibility(View.GONE); } LinearLayout stripList = (LinearLayout) rootView.findViewById(R.id.strips_list); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); if (comicItem.id.equals(ComicStripsContent.id) && ComicStripsContent.ITEMS.size() > unread) { unread = ComicStripsContent.ITEMS.size(); } for (int i = 1; i < unread; i++) { ImageView iv = new ImageView(getActivity()); iv.setId(Integer.MAX_VALUE - i); iv.setPadding(16, 16, 16, 0); iv.setContentDescription(getString(R.string.strip_description)); iv.setAdjustViewBounds(true); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO check if there is need of opening? or always open? openFullscreenStrip(v); } }); TextView tv = new TextView(getActivity()); tv.setId(i); tv.setPadding(16, 4, 16, 4); tv.setGravity(Gravity.CENTER); stripList.addView(iv, layoutParams); stripList.addView(tv, layoutParams); } if (!comicItem.id.equals(ComicStripsContent.id)) { new GetComicsStrips(comicItem.id, unread, rootView).execute(); } else { new GetComicsStrips(comicItem.id, unread, rootView).onPostExecute(null); } if (savedInstanceState != null && savedInstanceState.containsKey(VERTICAL_SCROLLING_POSITION) && VERSION.SDK_INT >= 14) { rootView.findViewById(R.id.comic_scrollView).scrollTo(0, savedInstanceState.getInt(VERTICAL_SCROLLING_POSITION)); } return rootView; }
From source file:com.adarshahd.indianrailinfo.donate.PNRStat.java
private void createTableLayoutTrnDtls() { if (mPageResult.contains("FLUSHED PNR / ") || mPageResult.contains("Invalid PNR")) { mTextViewPNRSts.setText("The PNR entered is either invalid or expired! Please check."); mFrameLayout.removeAllViews();/*www . j a va 2 s .co m*/ mFrameLayout.addView(mTextViewPNRSts); return; } if (mPageResult.contains("Connectivity Failure") || mPageResult.contains("try again")) { mTextViewPNRSts.setText("Looks like server is busy or currently unavailable. Please try again later!"); mFrameLayout.removeAllViews(); mFrameLayout.addView(mTextViewPNRSts); return; } List<String> trainList; if (mTrainDetails == null || mTrainDetails.getPNR() != mPNRNumber) { Elements eleTrain = Jsoup.parse(mPageResult).select("table tr tr td:containsOwn(Train Number)"); Iterator iteTrain = null; try { iteTrain = eleTrain.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("PNRStat", mPageResult); return; } trainList = new ArrayList<String>(); Element tmp; //Get the third row for train details iteTrain.next(); iteTrain.next(); if (iteTrain.hasNext()) { tmp = (Element) iteTrain.next(); trainList.add(tmp.select("td").get(0).text()); trainList.add(tmp.select("td").get(1).text()); trainList.add(tmp.select("td").get(2).text()); trainList.add(tmp.select("td").get(5).text()); trainList.add(tmp.select("td").get(6).text()); trainList.add(tmp.select("td").get(7).text()); } mTrainDetails = new TrainDetails(trainList, mPNRNumber); } else { trainList = mTrainDetails.getTrainDetails(); } mTableLayoutTrn = new TableLayout(mActivity); mTableLayoutTrn.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TableRow row = new TableRow(mActivity); mStrTrainDetails = new String(); row.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (String list : trainList) { TextView tv = new TextView(mActivity); tv.setText(list); tv.setPadding(10, 10, 10, 10); tv.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Small); row.addView(tv); mStrTrainDetails += list + " "; } row.setBackgroundResource(R.drawable.card_background); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTableLayoutTrn.addView(row); }
From source file:com.gmobi.poponews.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); int px = DipHelper.dip2px(50); tab.setHeight(px);/* w w w.j a va 2 s . co m*/ px = DipHelper.dip2px(90); tab.setPadding(20, 0, 20, 0); tab.setText(title); tab.setTextAppearance(this.getContext(), R.style.TabTextStyle); tab.setGravity(Gravity.CENTER); tab.setShadowLayer((float) 0.01, 0, (float) 1.0, 0xffffff); addTab(position, tab); }
From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java
@Override public View getView(int position, View convertView, ViewGroup parent) { TextView txt = (TextView) convertView; if (txt == null) { txt = new TextView(getApplication()); txt.setPadding(UI._8dp, UI._4dp, UI._8dp, UI._4dp); txt.setTypeface(UI.defaultTypeface); txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); txt.setTextColor(defaultTextColors); }/*from w ww. j ava 2 s . co m*/ txt.setText(getGenreString(position)); return txt; }
From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java
@Override public View getDropDownView(int position, View convertView, ViewGroup parent) { TextView txt = (TextView) convertView; if (txt == null) { txt = new TextView(getApplication()); txt.setPadding(UI._DLGdppad, UI._DLGsppad, UI._DLGdppad, UI._DLGsppad); txt.setTypeface(UI.defaultTypeface); txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); txt.setTextColor(defaultTextColors); }//from ww w . j a v a2s . co m txt.setText(getGenreString(position)); return txt; }