List of usage examples for android.util TypedValue COMPLEX_UNIT_PX
int COMPLEX_UNIT_PX
To view the source code for android.util TypedValue COMPLEX_UNIT_PX.
Click Source Link
From source file:com.github.takumalee.simplematerialtabpager.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); // v.setBackgroundResource(tabBackgroundColor != 0 ? tabBackgroundColor : tabBackgroundResId); v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom()); if (v instanceof TextView) { TextView tabText = (TextView) v.findViewById(R.id.psts_tab_title); if (tabText != null) { tabText.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tabText.setAllCaps(true); } else { tabText.setText(tabText.getText().toString().toUpperCase(locale)); }//from w w w . ja v a 2 s.c o m } } } } }
From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java
@Override public void onClick(View view) { if (view == btnGoBack) { if (isAtFavorites) { isAtFavorites = false;/*from w ww .ja v a 2 s .c om*/ doSearch(); } else { finish(0, view, true); } } else if (view == btnFavorite) { isAtFavorites = true; radioStationList.cancel(); radioStationList.fetchFavorites(getApplication()); updateButtons(); } else if (view == btnSearch) { final Context ctx = getHostActivity(); final LinearLayout l = (LinearLayout) UI.createDialogView(ctx, null); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); chkGenre = new RadioButton(ctx); chkGenre.setText(R.string.genre); chkGenre.setChecked(Player.lastRadioSearchWasByGenre); chkGenre.setOnClickListener(this); chkGenre.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); chkGenre.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; btnGenre = new Spinner(ctx); btnGenre.setContentDescription(ctx.getText(R.string.genre)); btnGenre.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad << 1; chkTerm = new RadioButton(ctx); chkTerm.setText(R.string.search_term); chkTerm.setChecked(!Player.lastRadioSearchWasByGenre); chkTerm.setOnClickListener(this); chkTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); chkTerm.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; txtTerm = new EditText(ctx); txtTerm.setContentDescription(ctx.getText(R.string.search_term)); txtTerm.setText(Player.radioSearchTerm == null ? "" : Player.radioSearchTerm); txtTerm.setOnClickListener(this); txtTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); txtTerm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); txtTerm.setSingleLine(); txtTerm.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; p.bottomMargin = UI._DLGsppad; final TextView lbl = new TextView(ctx); lbl.setAutoLinkMask(0); lbl.setLinksClickable(true); //http://developer.android.com/design/style/color.html lbl.setLinkTextColor(new BgColorStateList(UI.isAndroidThemeLight() ? 0xff0099cc : 0xff33b5e5)); lbl.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._14sp); lbl.setGravity(Gravity.CENTER_HORIZONTAL); lbl.setText(SafeURLSpan.parseSafeHtml(getText(R.string.by_dir_xiph_org))); lbl.setMovementMethod(LinkMovementMethod.getInstance()); lbl.setLayoutParams(p); l.addView(chkGenre); l.addView(btnGenre); l.addView(chkTerm); l.addView(txtTerm); l.addView(lbl); btnGenre.setAdapter(this); btnGenre.setSelection(getValidGenre(Player.radioLastGenre)); defaultTextColors = txtTerm.getTextColors(); UI.prepareDialogAndShow((new AlertDialog.Builder(ctx)).setTitle(getText(R.string.search)).setView(l) .setPositiveButton(R.string.search, this).setNegativeButton(R.string.cancel, this) .setOnCancelListener(this).create()); } else if (view == btnGoBackToPlayer) { finish(-1, view, false); } else if (view == btnAdd) { addPlaySelectedItem(false); } else if (view == btnPlay) { addPlaySelectedItem(true); } else if (view == chkGenre || view == btnGenre) { chkGenre.setChecked(true); chkTerm.setChecked(false); } else if (view == chkTerm || view == txtTerm) { chkGenre.setChecked(false); chkTerm.setChecked(true); } else if (view == list) { if (!isAtFavorites && !loading && (radioStationList == null || radioStationList.getCount() == 0)) onClick(btnFavorite); } }
From source file:com.yj.smarthome.activity.control.MainControlActivity.java
/** * Inits the views./*from w w w . j ava2 s.c om*/ */ private void initViews() { tv_camera = (TextView) findViewById(R.id.tvCamera); mViewPager = (ViewPager) findViewById(R.id.pager); pagerTabStrip = (PagerTabStrip) findViewById(R.id.pager_tab_strip); // pagerTabStrip.setTextSize(TypedValue.COMPLEX_UNIT_PX, 50); // pagerTabStrip.setTabIndicatorColor(getResources().getColor(R.color.indicatorcolor)); myPagerAdapter = new MyPagerAdapter(); mViewPager.setAdapter(myPagerAdapter); rlAlarmTips = (RelativeLayout) findViewById(R.id.rlAlarmTips); tvAlarmTipsCount = (TextView) findViewById(R.id.tvAlarmTipsCount); drawerLayout = (DrawerLayout) findViewById(R.id.main_layout); rlControlMainPage = (RelativeLayout) findViewById(R.id.rlControlMainPage); ivMenu = (ImageView) findViewById(R.id.ivMenu); tvTitle = (TextView) findViewById(R.id.tvTitle); mFaultDialog = DialogManager.getDeviceErrirDialog(MainControlActivity.this, "", new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:10010")); startActivity(intent); mFaultDialog.dismiss(); } }); mAdapter = new MenuDeviceAdapter(this, bindlist); progressDialogRefreshing = new ProgressDialog(MainControlActivity.this); progressDialogRefreshing.setMessage("?,??"); progressDialogRefreshing.setCancelable(false); mDisconnectDialog = DialogManager.getDisconnectDialog(this, new OnClickListener() { @Override public void onClick(View v) { DialogManager.dismissDialog(MainControlActivity.this, mDisconnectDialog); IntentUtils.getInstance().startActivity(MainControlActivity.this, DeviceListActivity.class); finish(); } }); //??? drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer_am, R.string.open_darwlayout, R.string.close_darwlayout) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; drawerLayout.setDrawerListener(drawerToggle); drawerToggle.syncState(); }
From source file:gr.scify.newsum.ui.ViewActivity.java
private void initZoomControls() { final TextView tx = (TextView) findViewById(R.id.textView1); final float minm = tx.getTextSize(); final float maxm = (minm + 24); // Add zoom controls ZoomControls zoom = (ZoomControls) findViewById(R.id.zoomControls1); zoom.setOnZoomInClickListener(new OnClickListener() { @Override/*from www . j a v a 2 s .c o m*/ public void onClick(View v) { if (tx.getTextSize() < maxm) { tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, tx.getTextSize() + 2); SharedPreferences textsize = getSharedPreferences("textS", 0); SharedPreferences.Editor editor = textsize.edit(); editor.putFloat("size", tx.getTextSize()); editor.commit(); } } }); zoom.setOnZoomOutClickListener(new OnClickListener() {// to the default // size @Override public void onClick(View v) { if (tx.getTextSize() > minm) tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, tx.getTextSize() - 2); SharedPreferences textsize = getSharedPreferences("textS", 0); SharedPreferences.Editor editor = textsize.edit(); editor.putFloat("size", tx.getTextSize()); editor.commit(); } }); }
From source file:com.luseen.spacenavigation.SpaceNavigationView.java
/** * Adding given space items to content//ww w.j a v a 2 s . co m * * @param leftContent to left content * @param rightContent and right content */ private void addSpaceItems(LinearLayout leftContent, LinearLayout rightContent) { /** * Removing all views for not being duplicated */ if (leftContent.getChildCount() > 0 || rightContent.getChildCount() > 0) { leftContent.removeAllViews(); rightContent.removeAllViews(); } /** * Clear spaceItemList and badgeList for not being duplicated */ spaceItemList.clear(); badgeList.clear(); /** * Getting LayoutInflater to inflate space item view from XML */ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < spaceItems.size(); i++) { final int index = i; int targetWidth; if (spaceItems.size() > 2) targetWidth = contentWidth / 2; else targetWidth = contentWidth; RelativeLayout.LayoutParams textAndIconContainerParams = new RelativeLayout.LayoutParams(targetWidth, mainContentHeight); RelativeLayout textAndIconContainer = (RelativeLayout) inflater.inflate(R.layout.space_item_view, this, false); textAndIconContainer.setLayoutParams(textAndIconContainerParams); ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon); TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text); RelativeLayout badgeContainer = (RelativeLayout) textAndIconContainer .findViewById(R.id.badge_container); spaceItemIcon.setImageResource(spaceItems.get(i).getItemIcon()); spaceItemText.setText(spaceItems.get(i).getItemName()); spaceItemText.setTextSize(TypedValue.COMPLEX_UNIT_PX, spaceItemTextSize); /** * Set custom font to space item textView */ if (isCustomFont) spaceItemText.setTypeface(customFont); /** * Hide item icon and show only text */ if (textOnly) Utils.changeViewVisibilityGone(spaceItemIcon); /** * Hide item text and change icon size */ ViewGroup.LayoutParams iconParams = spaceItemIcon.getLayoutParams(); if (iconOnly) { iconParams.height = spaceItemIconOnlySize; iconParams.width = spaceItemIconOnlySize; spaceItemIcon.setLayoutParams(iconParams); Utils.changeViewVisibilityGone(spaceItemText); } else { iconParams.height = spaceItemIconSize; iconParams.width = spaceItemIconSize; spaceItemIcon.setLayoutParams(iconParams); } /** * Adding space items to item list for future */ spaceItemList.add(textAndIconContainer); /** * Adding badge items to badge list for future */ badgeList.add(badgeContainer); /** * Adding sub views to left and right sides */ if (spaceItems.size() == 2 && leftContent.getChildCount() == 1) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else if (spaceItems.size() > 2 && leftContent.getChildCount() == 2) { rightContent.addView(textAndIconContainer, textAndIconContainerParams); } else { leftContent.addView(textAndIconContainer, textAndIconContainerParams); } /** * Changing current selected item tint */ if (i == currentSelectedItem) { spaceItemText.setTextColor(activeSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, activeSpaceItemColor); } else { spaceItemText.setTextColor(inActiveSpaceItemColor); Utils.changeImageViewTint(spaceItemIcon, inActiveSpaceItemColor); } textAndIconContainer.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { updateSpaceItems(index); } }); } /** * Restore available badges from saveInstance */ restoreBadges(); }
From source file:com.eccyan.widget.SpinningTabStrip.java
private void updateTabStyles() { for (int i = 0; i < realTabCount; i++) { View v = tabsContainer.getChildAt(i); if (!(pager.getAdapter() instanceof CustomTabProvider)) { v.setBackgroundResource(tabBackgroundResId); }/*from w w w . j a v a2 s. co m*/ v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom()); TextView tabTitle = (TextView) v.findViewById(R.id.tab_title); if (tabTitle != null) { tabTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tabTitle.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle); if (tabTextColor != null) { tabTitle.setTextColor(tabTextColor); } // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tabTitle.setAllCaps(true); } else { tabTitle.setText(tabTitle.getText().toString().toUpperCase(locale)); } } } } }
From source file:koma.movieapp.ui.MovieDetailActivity.java
@Override public void onLoadFinished(Loader<Movie> loader, Movie movie) { mTitleString = movie.title;//from ww w .jav a 2 s .co m mMovieColor = getResources().getColor(R.color.default_movie_color); mHeaderBox.setBackgroundColor(mMovieColor); getLUtils().setStatusBarColor(UIUtils.scaleColor(mMovieColor, 0.8f, false)); final String movieRating = movie.vote_average.toString(); final String movieRuntime = movie.runtime.toString(); final String movieBackdropPath = movie.backdrop_path; final String movieOverview = movie.overview; /* Title */ final int titleLength = mTitleString.length(); final int textDimension; if (titleLength < Config.DETAILS_SHORT_TITLE) { textDimension = R.dimen.text_title_size_xxlarge; } else if (titleLength < Config.DETAILS_MEDIUM_TITLE) { textDimension = R.dimen.text_title_size_xlarge; } else if (titleLength < Config.DETAILS_LONG_TITLE) { textDimension = R.dimen.text_title_size_large; } else { textDimension = R.dimen.text_title_size_medium; } mTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(textDimension)); LOGD(TAG, "Title size: " + mTitle.getTextSize()); mTitle.setText(mTitleString); /* Rating */ if (!movieRating.isEmpty()) { mMovieRating.setVisibility(View.VISIBLE); mMovieRating.setText(movieRating + "/10"); } /* Runtime */ if (!movieRuntime.isEmpty()) { mMovieRuntime.setVisibility(View.VISIBLE); mMovieRuntime.setText(movieRuntime + " " + getResources().getString(R.string.minutes)); } /* Overview */ if (!movieOverview.isEmpty()) { mMovieOverview.setVisibility(View.VISIBLE); mMovieOverview.setText(movieOverview); } /* Backdrop */ final String baseBackdropUrl = Config.TMDB_IMAGE_BASE_URL + Config.TMDB_IMAGE_SIZE; final String backdropUrl = baseBackdropUrl + movieBackdropPath; if (movieBackdropPath != null) { mHasPhoto = true; mNoPlaceholderImageLoader.loadImage(backdropUrl, mPhotoView, new RequestListener<String>() { @Override public void onException(Exception e, String url, Target target) { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } @Override public void onImageReady(String url, Target target, boolean b, boolean b2) { // Trigger image transition recomputePhotoAndScrollingMetrics(); } }); recomputePhotoAndScrollingMetrics(); } else { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } /* Crew */ /* Director */ Credits creditsList = movie.credits; if (creditsList != null) { List<Credits.CrewMember> crewList = creditsList.crew; List<Credits.CastMember> castList = creditsList.cast; if (!crewList.isEmpty()) { ArrayList<Credits.CrewMember> directorList = new ArrayList<>(); //ArrayList<Credits.CrewMember> writerList = new ArrayList<>(); //ArrayList<Credits.CrewMember> producerList = new ArrayList<>(); for (Credits.CrewMember crewMember : crewList) { if (crewMember.department.equals("Directing")) { directorList.add(crewMember); } // if (crewMember.department.equals("Writing")) { // writerList.add(crewMember); // } // if (crewMember.department.equals("Production")) { // producerList.add(crewMember); // } } if (!directorList.isEmpty()) { mMovieDirectors.setVisibility(View.VISIBLE); TextView directorHeader = (TextView) findViewById(R.id.movie_director_header); directorHeader.setVisibility(View.VISIBLE); mMovieDirectors.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); for (Credits.CrewMember director : directorList) { TextView chipView = (TextView) inflater.inflate(R.layout.include_cast_crew_member, mMovieDirectors, false); chipView.setText(director.name); mMovieDirectors.addView(chipView); } } // if (!writerList.isEmpty()) { // mMovieWriters.setVisibility(View.VISIBLE); // LayoutInflater inflater = LayoutInflater.from(this); // // for (Credits.CrewMember writer : writerList) { // TextView chipView = (TextView) inflater.inflate( // R.layout.include_cast_crew_member, mMovieWriters, false); // chipView.setText(writer.name); // mMovieWriters.addView(chipView); // } // } // if (!producerList.isEmpty()) { // mMovieProducers.setVisibility(View.VISIBLE); // LayoutInflater inflater = LayoutInflater.from(this); // // for (Credits.CrewMember producer : producerList) { // TextView chipView = (TextView) inflater.inflate( // R.layout.include_cast_crew_member, mMovieProducers, false); // chipView.setText(producer.name); // mMovieProducers.addView(chipView); // } // } } if (!castList.isEmpty()) { mMovieCast.setVisibility(View.VISIBLE); mMovieCast.removeAllViews(); TextView castHeader = (TextView) findViewById(R.id.movie_cast_header); castHeader.setVisibility(View.VISIBLE); LayoutInflater inflater = LayoutInflater.from(this); for (Credits.CastMember castMember : castList) { if (castMember.order < 5) { TextView chipView = (TextView) inflater.inflate(R.layout.include_cast_crew_member, mMovieCast, false); chipView.setText(castMember.name); mMovieCast.addView(chipView); } } } } /* Genres */ List<Genre> genresList = movie.genres; if (!genresList.isEmpty()) { mMovieGenresContainer.setVisibility(View.VISIBLE); mMovieGenres.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); for (Genre genre : genresList) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mMovieGenres, false); chipView.setText(genre.name); mMovieGenres.addView(chipView); } } //updateEmptyView(); mAddScheduleButton.setVisibility(View.VISIBLE); mHandler.post(new Runnable() { @Override public void run() { onScrollChanged(0, 0); // trigger scroll handling mScrollViewChild.setVisibility(View.VISIBLE); //mMovieOverview.setTextIsSelectable(true); } }); // mTimeHintUpdaterRunnable = new Runnable() { // @Override // public void run() { // updateTimeBasedUi(); // mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); // } // }; //mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); }
From source file:pl.motyczko.scrollheader.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (!(v instanceof TextView)) continue; TextView tab = (TextView) v;/*from www . jav a 2 s . c o m*/ tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } }
From source file:com.jiandanbaoxian.widget.PagerSlidingTabStrip.java
/** * tabtab /* w w w. jav a 2 s.c o m*/ * * @param position * @param selectTabTextColor * @param unSelectTabTextColor */ public void setSelectTabTextColor(int position, int selectTabTextColor, int unSelectTabTextColor) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (i == position) { tab.setTextColor(selectTabTextColor); } else { tab.setTextColor(unSelectTabTextColor); } // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesView.java
private static void setupAlphabetKey(final TextView alphabetKey, final String label, final KeyDrawParams params) { alphabetKey.setText(label);/*from w w w . j a va 2 s . c o m*/ alphabetKey.setTextColor(params.mFunctionalTextColor); alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize); alphabetKey.setTypeface(params.mTypeface); }