List of usage examples for android.widget TextView setCompoundDrawablesWithIntrinsicBounds
@android.view.RemotableViewMethod public void setCompoundDrawablesWithIntrinsicBounds(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom)
From source file:com.yyjlr.tickets.viewutils.snakebar.TSnackbar.java
/** * @param resource_id image id//from ww w . j av a 2 s . c om * @param width image width * @param height image height * @return */ public TSnackbar addIcon(int resource_id, int width, int height) { final TextView tv = mView.getMessageView(); if (resource_id != -1) { if (width > 0 || height > 0) { tv.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(Bitmap.createScaledBitmap( ((BitmapDrawable) (mContext.getResources().getDrawable(resource_id))).getBitmap(), width, height, true)), null, null, null); } else { addIcon(resource_id); } } return this; }
From source file:com.superlity.test.recyclelistviewtest.emoji.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); ////from ww w .j a va 2s.c om int[] icons = { R.drawable.ic_emoji_recent, R.drawable.ic_emoji_smile, R.drawable.ic_emoji_flower, R.drawable.ic_emoji_bell, R.drawable.ic_emoji_car, R.drawable.ic_emoji_symbol, }; for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } // tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setCompoundDrawablesWithIntrinsicBounds(icons[i], 0, 0, 0); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:org.telegram.ui.ContactsActivity.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;//from w w w . ja va 2s .co m } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setCustomView(null); actionBar.setSubtitle(null); TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } if (destroyAfterSelect) { actionBar.setTitle(getStringEntry(R.string.SelectContact)); } else { actionBar.setTitle(getStringEntry(R.string.Contacts)); } ((ApplicationActivity) parentActivity).fixBackButton(); }
From source file:gujaratcm.anandiben.customui.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w w w .jav a 2 s . co m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); if (containIcons) { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(0, icons[i], 0, 0); } XmlResourceParser xrp = getResources().getXml(R.xml.tab_strip_text_selector); try { ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp); tabTitleView.setTextColor(csl); } catch (Exception e) { } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.example.angelina.travelapp.map.MapFragment.java
/** * Populate the place detail contained/*from w w w.ja v a2 s.c o m*/ * within the bottom sheet * @param place - Place item selected by user */ @Override public final void showDetail(final Place place) { final TextView txtName = (TextView) mBottomSheet.findViewById(R.id.placeName); txtName.setText(place.getName()); String address = place.getAddress(); final String[] splitStrs = TextUtils.split(address, ","); if (splitStrs.length > 0) { address = splitStrs[0]; } final TextView txtAddress = (TextView) mBottomSheet.findViewById(R.id.placeAddress); txtAddress.setText(address); final TextView txtPhone = (TextView) mBottomSheet.findViewById(R.id.placePhone); txtPhone.setText(place.getPhone()); final LinearLayout linkLayout = (LinearLayout) mBottomSheet.findViewById(R.id.linkLayout); // Hide the link placeholder if no link is found if (place.getURL().isEmpty()) { linkLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(0, 0)); linkLayout.requestLayout(); } else { final int height = (int) (48 * Resources.getSystem().getDisplayMetrics().density); linkLayout.setLayoutParams( new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height)); linkLayout.requestLayout(); final TextView txtUrl = (TextView) mBottomSheet.findViewById(R.id.placeUrl); txtUrl.setText(place.getURL()); } final TextView txtType = (TextView) mBottomSheet.findViewById(R.id.placeType); txtType.setText(place.getType()); // Assign the appropriate icon final Drawable d = CategoryHelper.getDrawableForPlace(place, getActivity()); txtType.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); // Center map on selected place mPresenter.centerOnPlace(place); mShowSnackbar = false; centeredPlaceName = place.getName(); }
From source file:vn.viettel.browser.utils.widget.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from w ww . j ava 2s . c o m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); if (mDrawableRightTabs != null && i < mDrawableRightTabs.length) { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mDrawableRightTabs[i], 0); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.orange.ocara.ui.activity.ResultAuditActivity.java
private View buildResumeRow(RequestCreator handicapIconRequest, String handicapName, AccessibilityStats stats, int rowIndex) { TableRow row = (TableRow) getLayoutInflater().inflate(com.orange.ocara.R.layout.result_resume_item, null); TextView noImpact = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_no_impact); TextView annoying = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_annoying); TextView blocking = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_blocking); TextView doubt = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_doubt); noImpact.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.ACCESSIBLE))); annoying.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.ANNOYING))); blocking.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.BLOCKING))); doubt.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.DOUBT))); final TextView handicapType = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_type); handicapType.setText(handicapName);//from ww w . j a v a 2 s . c om if (handicapIconRequest != null) { Target target = new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { handicapType.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(getResources(), bitmap), null, null, null); } @Override public void onBitmapFailed(Drawable errorDrawable) { } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } }; final int maxSize = getResources() .getDimensionPixelSize(com.orange.ocara.R.dimen.resultResumeHandicapIconSize); handicapIconRequest.placeholder(android.R.color.black).resize(maxSize, maxSize).into(target); } int backGroundColor = (rowIndex % 2 == 0) ? com.orange.ocara.R.color.resultTableColorEven : com.orange.ocara.R.color.resultTableColorOdd; row.setBackgroundResource(backGroundColor); return row; }
From source file:com.example.paco.app.SlidingTabLayout.java
private void populateTabStrip() { final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w ww . j a v a2 s . c om*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } //Set icon, that can be changeable instead setting text. //I think the text also can setting here from getPageTitle func. //But we interesting only in icon tabTitleView.setCompoundDrawablesWithIntrinsicBounds(0, adapter.getDrawableId(i), 0, 0); tabTitleView.setHeight(215); //Select tab if it is current if (mViewPager.getCurrentItem() == i) { tabView.setSelected(true); } tabView.setOnClickListener(tabClickListener); //tabTitleView.setText(adapter.getPageTitle(i)); //tabView.setOnClickListener(tabClickListener); //String desc = mContentDescriptions.get(i, null); //if (desc != null) { // tabView.setContentDescription(desc); //} mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.myapp.smartadvisingapp.SlidingTabLayout.java
private void populateTabStrip() { final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;// w ww. ja v a2 s. com TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } //Set icon, that can be changeable instead setting text. //I think the text also can setting here from getPageTitle func. //But we interesting only in icon tabTitleView.setCompoundDrawablesWithIntrinsicBounds(0, adapter.getDrawableId(i), 0, 0); tabTitleView.setHeight(215); //Select tab if it is current if (mViewPager.getCurrentItem() == i) { tabView.setSelected(true); } tabView.setOnClickListener(tabClickListener); //tabTitleView.setText(adapter.getPageTitle(i)); //tabView.setOnClickListener(tabClickListener); //String desc = mContentDescriptions.get(i, null); //if (desc != null) { // tabView.setContentDescription(desc); //} mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.mk4droid.IMC_Activities.Fragment_Issue_Details.java
/** * OnCreateView/*from ww w . ja va2 s . c o m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { isVisible = true; vfrag_issue_details = inflater.inflate(R.layout.fragment_issue_details, container, false); ctx = vfrag_issue_details.getContext(); resources = setResources(); mfrag_issue_details = this; //========= Image ================= dbHandler = new DatabaseHandler(ctx); imvFull = (ImageView) vfrag_issue_details.findViewById(R.id.imvIssue_Full); IssuePic issuepic = dbHandler.getIssuePic(mIssue._id); if (issuepic._IssuePicData != null) { bmI = My_System_Utils.LowMemBitmapDecoder(issuepic._IssuePicData); } else { //------- Try to download from internet -------------- if (InternetConnCheck.getInstance(ctx).isOnline(ctx) && !mIssue._urlphoto.equals("null") && !mIssue._urlphoto.equals("") && mIssue._urlphoto.length() > 0) { mIssue._urlphoto = mIssue._urlphoto.replaceFirst("/thumbs", ""); new ThumbnailTask_IssDetails(mIssue._urlphoto, mIssue._id).execute(); } } dbHandler.db.close(); imvFull.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialogZoomIm = null; if (FActivity_TabHost.IndexGroup == 0) dialogZoomIm = new Dialog(ctx, android.R.style.Theme_Black_NoTitleBar_Fullscreen); else if (FActivity_TabHost.IndexGroup == 1) dialogZoomIm = new Dialog(FActivity_TabHost.ctx, android.R.style.Theme_Black_NoTitleBar_Fullscreen); dialogZoomIm.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogZoomIm.setContentView(R.layout.custom_dialog); dialogZoomIm.show(); } }); // ============ Title and id ========= tv_id = (TextView) vfrag_issue_details.findViewById(R.id.tv_issuenumber); TextView tvTitB = (TextView) vfrag_issue_details.findViewById(R.id.tvTitleIssDetB); tv_id.setText(Html.fromHtml("<b><big>#</big></b> " + issueId)); tv_id.setMovementMethod(new ScrollingMovementMethod()); tvTitB.setText(mIssue._title); //=============== Description ====================== tvDescription = (TextView) vfrag_issue_details.findViewById(R.id.textViewDescription); if (!mIssue._description.equals("")) tvDescription.setText(mIssue._description); else { tvDescription.setVisibility(View.GONE); } // ============== CATEGORY =============================== TextView tvCateg = (TextView) vfrag_issue_details.findViewById(R.id.textViewCategContent); int iCateg = 0; for (int i = 0; i < Service_Data.mCategL.size(); i++) if (Service_Data.mCategL.get(i)._id == mIssue._catid) { iCateg = i; break; } tvCateg.setText(Service_Data.mCategL.get(iCateg)._name); try { bmCateg = My_System_Utils.LowMemBitmapDecoder(Service_Data.mCategL.get(iCateg)._icon); BitmapDrawable drCateg = new BitmapDrawable(bmCateg); tvCateg.setCompoundDrawablesWithIntrinsicBounds(drCateg, null, null, null); tvCateg.setCompoundDrawablePadding(10); tvCateg.postInvalidate(); } catch (Exception e) { } markerOptions = new MarkerOptions().position(new LatLng(mIssue._latitude, mIssue._longitude)) .title(mIssue._title).icon(BitmapDescriptorFactory.fromBitmap(bmCateg)); //================ STATUS ================ tvStatus_ack = (TextView) vfrag_issue_details.findViewById(R.id.tv_Status_issuedetails_ack); tvStatus_cl = (TextView) vfrag_issue_details.findViewById(R.id.tv_Status_issuedetails_cl); vStatus_ack = vfrag_issue_details.findViewById(R.id.v_Status_issuedetails_acknow); vStatus_cl = vfrag_issue_details.findViewById(R.id.v_Status_issuedetails_cl); int CurrStat = mIssue._currentstatus; Colora(CurrStat); // ============== Time and Author ================ TextView tvSubmitted = (TextView) vfrag_issue_details.findViewById(R.id.tvSubmitted); String TimeStampRep = mIssue._reported.replace("-", "/"); tvSubmitted.setText(resources.getString(R.string.Submitted) + " " + My_Date_Utils.SubtractDate(TimeStampRep, LangSTR) + " " + resources.getString(R.string.ago) + " " + resources.getString(R.string.by) + " " + mIssue._username); //============== Votes======================== TextView tvVotes = (TextView) vfrag_issue_details.findViewById(R.id.textViewVotes); tvVotes.setText(Integer.toString(mIssue._votes) + " " + resources.getString(R.string.peoplevoted)); Button btVote = (Button) vfrag_issue_details.findViewById(R.id.buttonVote); //-------- Check if state is Ack or Closed then can not vote ---- if (CurrStat == 2 || CurrStat == 3) btVote.setEnabled(false); //-------- Check if Has Voted ---------- DatabaseHandler dbHandler = new DatabaseHandler(ctx); HasVotedSW = dbHandler.CheckIfHasVoted(issueId); OwnIssue = false; if (UserID_STR.length() > 0) OwnIssue = dbHandler.checkIfOwnIssue(Integer.toString(issueId), UserID_STR); dbHandler.db.close(); // if has not voted, it is not his issue, and authenticated then able to vote if (!OwnIssue && !HasVotedSW && AuthFlag) { btVote.setEnabled(true); } if (OwnIssue || HasVotedSW) { btVote.setEnabled(false); btVote.setText(resources.getString(R.string.AlreadyVoted)); } if (!AuthFlag) { btVote.setText(resources.getString(R.string.Vote)); } btVote.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { if (InternetConnCheck.getInstance(ctx).isOnline(ctx) && AuthFlag) { new AsynchTaskVote().execute(); } else if (!InternetConnCheck.getInstance(ctx).isOnline(ctx)) { Toast.makeText(ctx, resources.getString(R.string.NoInternet), Toast.LENGTH_SHORT).show(); } else if (!AuthFlag) { Toast.makeText(ctx, resources.getString(R.string.OnlyRegistered), Toast.LENGTH_SHORT).show(); } } }); //============ Address - MapStatic - Button Map dynamic ======================== TextView tvAddr = (TextView) vfrag_issue_details.findViewById(R.id.textViewAddressContent); tvAddr.setText(mIssue._address); fmap_issdet = SupportMapFragment.newInstance(); FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.lliss_det_map, fmap_issdet); fragmentTransaction.commit(); // ============ COMMENTS =========================== Button btCommentsSW = (Button) vfrag_issue_details.findViewById(R.id.btCommentsSW); btCommentsSW.setText(resources.getString(R.string.ViewComments)); btCommentsSW.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (InternetConnCheck.getInstance(ctx).isOnline(ctx)) { FragmentTransaction ft2 = getFragmentManager().beginTransaction(); Fragment_Comments newfrag_comments = new Fragment_Comments(); // Instantiate a new fragment. Bundle args = new Bundle(); args.putInt("issueId", issueId); args.putString("issueTitle", mIssue._title); newfrag_comments.setArguments(args); // Add the fragment to the activity, pushing this transaction on to the back stack. if (FActivity_TabHost.IndexGroup == 0) ft2.add(R.id.flmain, newfrag_comments, "FTAG_COMMENTS"); else if (FActivity_TabHost.IndexGroup == 1) { ft2.add(R.id.fl_IssuesList_container, newfrag_comments, "FTAG_COMMENTS"); } ft2.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft2.addToBackStack(null); ft2.commit(); } else { Toast.makeText(ctx, resources.getString(R.string.NoInternet), Toast.LENGTH_SHORT).show(); } } }); return vfrag_issue_details; }