Java Code Examples for android.widget.Button#setTypeface()
The following examples show how to use
android.widget.Button#setTypeface() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnackBarItem.java From SnackBar with Apache License 2.0 | 6 votes |
/** * Sets up the action button if available * * @param action */ private void setupActionButton(Button action) { action.setVisibility(View.VISIBLE); action.setText(mActionMessage.toUpperCase()); action.setTextColor(mActionColor); if (mActionTextAppearance != -1) action.setTextAppearance(mActivity, mActionTextAppearance); if (mActionTypeface != null) action.setTypeface(mActionTypeface); action.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mActionButtonPressed = true; mShouldDisposeOnCancel = false; mAnimator.cancel(); if (mActionClickListener != null) mActionClickListener.onClick(view); createHideAnimation(); } }); }
Example 2
Source File: MainActivity.java From journaldev with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_fonts); /*ambleBold=(TextView)findViewById(R.id.ambleBold); ambleLight=(TextView)findViewById(R.id.ambleLight); ambleRegular=(TextView)findViewById(R.id.ambleRegular); openSansRegular=(TextView)findViewById(R.id.opRegular); openSansItalic=(TextView)findViewById(R.id.opItalic);*/ btn=(Button)findViewById(R.id.pacifico); /*ambleBold.setTypeface(Typeface.createFromAsset(getAssets(), A_BOLD)); ambleLight.setTypeface(Typeface.createFromAsset(getAssets(), A_LIGHT)); ambleRegular.setTypeface(Typeface.createFromAsset(getAssets(), A_REGULAR)); openSansRegular.setTypeface(Typeface.createFromAsset(getAssets(), O_REGULAR)); openSansItalic.setTypeface(Typeface.createFromAsset(getAssets(), O_ITALIC));*/ btn.setTypeface(Typeface.createFromAsset(getAssets(), P_REGULAR)); }
Example 3
Source File: BotInit.java From iGap-Android with GNU Affero General Public License v3.0 | 6 votes |
private void addButton(LinearLayout layout, String name, String action) { LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f); param.setMargins(2, 2, 2, 2); Button btn = new Button(G.context); btn.setLayoutParams(param); btn.setTextColor(Color.WHITE); btn.setBackgroundColor(ContextCompat.getColor(G.context, R.color.backgroundColorCall2)); btn.setText(name); btn.setAllCaps(false); btn.setTypeface(G.typeface_IRANSansMobile); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (G.onBotClick != null) { G.onBotClick.onBotCommandText(action); } setLayoutBot(true, false); } }); layout.addView(btn); }
Example 4
Source File: RedSnackbar.java From android with MIT License | 6 votes |
@NonNull public static Snackbar make(@NonNull View view, @NonNull CharSequence text, int duration) { final Snackbar snackbar = Snackbar.make(view, text, duration); try { final ViewGroup group = (ViewGroup) snackbar.getView(); group.setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.color_primary_dark)); snackbar.setActionTextColor(ContextCompat.getColor(view.getContext(), R.color.cream1)); final TextView tv = (TextView) (snackbar.getView()).findViewById(android.support.design.R.id.snackbar_text); tv.setTypeface(TypefaceHelper.getTypeface(view.getContext(), Const.TypeFaces.BOLD)); final Button btn = (Button) (snackbar.getView()).findViewById(android.support.design.R.id.snackbar_action); btn.setTypeface(TypefaceHelper.getTypeface(view.getContext(), Const.TypeFaces.BOLD)); } catch (Exception e) { e.printStackTrace(); } return snackbar; }
Example 5
Source File: AddItemActivity.java From Ucount with GNU General Public License v3.0 | 5 votes |
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_item); addCostBtn = (Button) findViewById(R.id.add_cost_button); addEarnBtn = (Button) findViewById(R.id.add_earn_button); addFinishBtn = (ImageButton) findViewById(R.id.add_finish); addDescription = (ImageButton) findViewById(R.id.add_description); clearBtn = (Button) findViewById(R.id.clear); words = (TextView) findViewById(R.id.anime_words); // 设置字体颜色 Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/chinese_character.ttf"); clearBtn.setTypeface(typeface); words.setTypeface(typeface); // 设置按钮监听 addCostBtn.setOnClickListener(new ButtonListener()); addEarnBtn.setOnClickListener(new ButtonListener()); addFinishBtn.setOnClickListener(new ButtonListener()); addDescription.setOnClickListener(new ButtonListener()); clearBtn.setOnClickListener(new ButtonListener()); bannerText = (TextView) findViewById(R.id.chosen_title); bannerImage = (ImageView) findViewById(R.id.chosen_image); moneyText = (TextView) findViewById(R.id.input_money_text); // 及时清零 moneyText.setText("0.00"); manager = getSupportFragmentManager(); transaction = manager.beginTransaction(); transaction.replace(R.id.item_fragment, new CostFragment()); transaction.commit(); }
Example 6
Source File: AppUpdate.java From XERUNG with Apache License 2.0 | 5 votes |
private void findView(){ txtThisVersion = (TextView)findViewById(R.id.txtThisVersionOf); txtThisVersion.setTypeface(ManagerTypeface.getTypeface(AppUpdate.this, R.string.typeface_roboto_regular)); btnDownload = (Button)findViewById(R.id.btnDownloadApp); btnDownload.setTypeface(ManagerTypeface.getTypeface(AppUpdate.this, R.string.typeface_roboto_regular)); txtAppUpdate = (TextView)findViewById(R.id.txtAppUpdateMainHead); }
Example 7
Source File: VerifyOTP.java From XERUNG with Apache License 2.0 | 5 votes |
private void findViewids() { txtApp = (TextView) findViewById(R.id.txtAppName); txtApp.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_android)); txtOTPNote = (TextView) findViewById(R.id.txtvalidateOtp); txtOTPNote.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); layBack = (RelativeLayout)findViewById(R.id.layBack); txtTimer = (TextView)findViewById(R.id.txttimer); txtTimer.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); btnResend = (Button)findViewById(R.id.btnResendOTP); btnResend.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); txtMobile = (TextView)findViewById(R.id.txtMobile); txtMobile.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); edtOTP = (MaterialEditText)findViewById(R.id.edtOTP); edtOTP.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); //edtOTP.setText(shared.getSharedValue("mOTP")); btnVerifyOTP = (ImageView)findViewById(R.id.btn_verify_otp); layUserDetails = (CardView) findViewById(R.id.layUserDetails); edtName =(MaterialEditText)findViewById(R.id.edtName); edtName.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); relAlreadyUser = (RelativeLayout)findViewById(R.id.relAlreadyUser); layNewUser = (LinearLayout)findViewById(R.id.layNewUser); btnCreate = (Button)findViewById(R.id.btnCreateAccount); btnCreate.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); txtIAgree = (TextView)findViewById(R.id.txtTermsCondt); txtIAgree.setTypeface(ManagerTypeface.getTypeface(VerifyOTP.this, R.string.typeface_roboto_regular)); countDownTimer = new MyCountDownTimer(startTime, interval); txtTimer.setText(String.valueOf(startTime / 1000)+"s"); spEmail = (MaterialSpinner)findViewById(R.id.spEmail); countDownTimer.start(); setAdapter(); }
Example 8
Source File: RebootDialog.java From fontster with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); final View view = View.inflate(getContext(), R.layout.reboot_dialog, null); ButterKnife.bind(this, view); setView(view); final AssetManager assets = view.getContext().getAssets(); final Typeface regular = Typeface.createFromAsset(assets, REGULAR_FONT); final Typeface bold = Typeface.createFromAsset(assets, BOLD_FONT); final TextView rebootMessage = (TextView) view.findViewById(R.id.reboot_message); rebootMessage.setTypeface(regular); final String buttonText = view.getContext().getString(R.string.reboot_dialog_button_text); setButton(BUTTON_POSITIVE, buttonText, (dialog, which) -> { dialog.dismiss(); Observable.just("reboot") .map(Collections::singletonList) .map(CommandRunner::run) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { }, error -> toast(R.string.reboot_failed, getContext())); }); super.onCreate(savedInstanceState); final Button button = getButton(AlertDialog.BUTTON_POSITIVE); button.setTypeface(bold); }
Example 9
Source File: HomeActivity.java From microbit with Apache License 2.0 | 5 votes |
/** * Sets buttons font style by setting an appropriate typeface. */ private void setupButtonsFontStyle() { Typeface typeface = MBApp.getApp().getTypeface(); Button connectButton = (Button) findViewById(R.id.connect_device_btn); connectButton.setTypeface(typeface); Button flashButton = (Button) findViewById(R.id.flash_microbit_btn); flashButton.setTypeface(typeface); Button createCodeButton = (Button) findViewById(R.id.create_code_btn); createCodeButton.setTypeface(typeface); Button discoverButton = (Button) findViewById(R.id.discover_btn); discoverButton.setTypeface(typeface); }
Example 10
Source File: GroupUserProfile.java From XERUNG with Apache License 2.0 | 4 votes |
private void findViewids() { txtApp = (TextView) findViewById(R.id.txtAppName); txtApp.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_android)); layBack = (RelativeLayout)findViewById(R.id.layBack); imagePhoto = (CircleImageView)findViewById(R.id.imgProfilePicSet); txtName = (TextView)findViewById(R.id.txtName); txtName.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtUserName = (TextView)findViewById(R.id.txtUserName); txtUserName.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtEmail = (TextView)findViewById(R.id.txtEmail); txtEmail.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); imgEmail = (ImageView)findViewById(R.id.imgEmail); layEmail = (LinearLayout)findViewById(R.id.layEmail); txtMobile = (TextView)findViewById(R.id.txtMobile); txtMobile.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); imgMobCall = (ImageView)findViewById(R.id.imgCallMob); layMob = (LinearLayout)findViewById(R.id.layMob); txtAlternateNumber = (TextView)findViewById(R.id.txtAlternateMobile); txtBloodGroup = (TextView)findViewById(R.id.txtBloodGroup); txtAlternateNumber.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtBloodGroup.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); imgAltCall = (ImageView)findViewById(R.id.imgCallAlt); layAlt = (LinearLayout)findViewById(R.id.layAltMob); txtProfession = (TextView)findViewById(R.id.txtProfession); txtProfession.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtAddress = (TextView)findViewById(R.id.txtAddress); txtAddress.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtCity = (TextView)findViewById(R.id.txtCity); txtCity.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtCountry = (TextView)findViewById(R.id.txtCountry); txtCountry.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtCompany = (TextView)findViewById(R.id.txtCompany); txtCompany.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtMakeAdmin = (Button) findViewById(R.id.txtMadeAdmin); txtMakeAdmin.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtUserStatus = (TextView)findViewById(R.id.txtUserStatus); txtUserStatus.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); imgSave = (ImageView)findViewById(R.id.imgSave); relProgress = (RelativeLayout)findViewById(R.id.layProgressresult); relInternet = (RelativeLayout)findViewById(R.id.layinternetresult); relNetwork = (RelativeLayout)findViewById(R.id.layNoresultserver); txtInternet = (TextView)findViewById(R.id.txtnoinertnettestresult); txtInternet.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); txtnetwork = (TextView)findViewById(R.id.txtNoresultnetwork); txtnetwork.setTypeface(ManagerTypeface.getTypeface(GroupUserProfile.this, R.string.typeface_roboto_regular)); scrollMain = (ScrollView)findViewById(R.id.laymain); imgDelete = (ImageView)findViewById(R.id.imgDelete); }
Example 11
Source File: TypefaceUtil.java From storage-chooser with Mozilla Public License 2.0 | 4 votes |
public static void setTypefaceSemiBold(Context context, Button button) { mNunitoTypeFace = Typeface.createFromAsset(context.getAssets(), "fonts/NunitoSans-Light.ttf"); button.setTypeface(mNunitoTypeFace); }
Example 12
Source File: StateView.java From StateViews with MIT License | 4 votes |
private void setButtonFont(Button button, Typeface typeface) { if (typeface != null) { button.setTypeface(typeface); } }
Example 13
Source File: TypefaceUtil.java From storage-chooser with Mozilla Public License 2.0 | 4 votes |
public static void setTypefaceLight(Context context, Button button) { mNunitoTypeFace = Typeface.createFromAsset(context.getAssets(), "fonts/NunitoSans-SemiBold.ttf"); button.setTypeface(mNunitoTypeFace); }
Example 14
Source File: ProjectAdapter.java From microbit with Apache License 2.0 | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { Project project = mProjects.get(position); if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(MBApp.getApp()); convertView = inflater.inflate(R.layout.project_items, null); } Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton); appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface()); ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit); appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface()); LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram); if(actionBarLayout != null) { if(project.actionBarExpanded) { actionBarLayout.setVisibility(View.VISIBLE); appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp() , R.drawable.ic_arrow_down), null); } else { actionBarLayout.setVisibility(View.GONE); appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp() , R.drawable.ic_arrow_left), null); } } appNameButton.setText(project.name); appNameButton.setTag(R.id.positionId, position); appNameButton.setTag(R.id.textEdit, appNameEdit); appNameButton.setOnClickListener(appNameClickListener); appNameButton.setOnLongClickListener(appNameLongClickListener); appNameEdit.setTag(R.id.positionId, position); appNameEdit.setTag(R.id.editbutton, appNameButton); appNameEdit.setOnEditorActionListener(editorOnActionListener); appNameEdit.setFilters(new InputFilter[]{renameFilter}); if(project.inEditMode) { appNameEdit.setVisibility(View.VISIBLE); appNameEdit.setText(project.name); appNameEdit.setSelection(project.name.length()); appNameEdit.requestFocus(); appNameButton.setVisibility(View.INVISIBLE); } else { appNameEdit.setVisibility(View.INVISIBLE); appNameButton.setVisibility(View.VISIBLE); //dismissKeyBoard(appNameEdit, false); } //appNameEdit.setOnClickListener(appNameClickListener); TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text); flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface()); LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn); sendBtnLayout.setTag(position); sendBtnLayout.setOnClickListener(sendBtnClickListener); ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn); deleteBtn.setTag(position); deleteBtn.setOnClickListener(deleteBtnClickListener); deleteBtn.setEnabled(true); Drawable myIcon; if(project.runStatus) { flashBtnText.setText(""); myIcon = convertView.getResources().getDrawable(R.drawable.green_btn); } else { flashBtnText.setText(R.string.flash); myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn); } sendBtnLayout.setBackground(myIcon); sendBtnLayout.setClickable(true); return convertView; }
Example 15
Source File: PairingActivity.java From microbit with Apache License 2.0 | 4 votes |
/** * Setup font styles by setting an appropriate typefaces. */ private void setupFontStyle() { ImageView ohPrettyImg = (ImageView) findViewById(R.id.oh_pretty_emoji); ohPrettyImg.setVisibility(View.INVISIBLE); MBApp application = MBApp.getApp(); Typeface defaultTypeface = application.getTypeface(); deviceConnectionStatusBtn.setTypeface(defaultTypeface); // Connect Screen TextView appBarTitle = (TextView) findViewById(R.id.flash_projects_title_txt); appBarTitle.setTypeface(defaultTypeface); TextView pairBtnText = (TextView) findViewById(R.id.custom_pair_button_text); pairBtnText.setTypeface(defaultTypeface); Typeface boldTypeface = application.getTypefaceBold(); TextView manageMicrobit = (TextView) findViewById(R.id.title_manage_microbit); manageMicrobit.setTypeface(boldTypeface); TextView manageMicorbitStatus = (TextView) findViewById(R.id.device_status_txt); manageMicorbitStatus.setTypeface(boldTypeface); // How to pair your micro:bit - Screen #1 TextView pairTipTitle = (TextView) findViewById(R.id.pairTipTitle); pairTipTitle.setTypeface(boldTypeface); TextView stepOneTitle = (TextView) findViewById(R.id.pair_tip_step_1_step); stepOneTitle.setTypeface(boldTypeface); // Step 2 - Enter Pattern TextView enterPatternTitle = (TextView) findViewById(R.id.enter_pattern_step_2_title); enterPatternTitle.setTypeface(boldTypeface); TextView stepTwoTitle = (TextView) findViewById(R.id.pair_enter_pattern_step_2); stepTwoTitle.setTypeface(boldTypeface); // Step 3 - Searching for micro:bit TextView searchMicrobitTitle = (TextView) findViewById(R.id.search_microbit_step_3_title); searchMicrobitTitle.setTypeface(boldTypeface); TextView stepThreeTitle = (TextView) findViewById(R.id.searching_microbit_step); stepThreeTitle.setTypeface(boldTypeface); Typeface robotoTypeface = application.getRobotoTypeface(); TextView descriptionManageMicrobit = (TextView) findViewById(R.id.description_manage_microbit); descriptionManageMicrobit.setTypeface(robotoTypeface); TextView problemsMicrobit = (TextView) findViewById(R.id.connect_microbit_problems_message); problemsMicrobit.setTypeface(robotoTypeface); TextView stepOneInstructions = (TextView) findViewById(R.id.pair_tip_step_1_instructions); stepOneInstructions.setTypeface(robotoTypeface); Button cancelPairButton = (Button) findViewById(R.id.cancel_tip_step_1_btn); cancelPairButton.setTypeface(robotoTypeface); Button nextPairButton = (Button) findViewById(R.id.ok_tip_step_1_btn); nextPairButton.setTypeface(robotoTypeface); TextView stepTwoInstructions = (TextView) findViewById(R.id.pair_enter_pattern_step_2_instructions); stepTwoInstructions.setTypeface(robotoTypeface); Button cancelEnterPattern = (Button) findViewById(R.id.cancel_enter_pattern_step_2_btn); cancelEnterPattern.setTypeface(robotoTypeface); Button okEnterPatternButton = (Button) findViewById(R.id.ok_enter_pattern_step_2_btn); okEnterPatternButton.setTypeface(robotoTypeface); TextView stepThreeInstructions = (TextView) findViewById(R.id.searching_microbit_step_instructions); stepThreeInstructions.setTypeface(robotoTypeface); Button cancelSearchMicroBit = (Button) findViewById(R.id.cancel_search_microbit_step_3_btn); cancelSearchMicroBit.setTypeface(robotoTypeface); }
Example 16
Source File: PlaylistFragment.java From Rey-MusicPlayer with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_album_layout, container, false); mContext = getContext(); setHasOptionsMenu(true); mApp = (Common) mContext.getApplicationContext(); mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); mFastScroller = (FastScroller) view.findViewById(R.id.fast_scroller); TextView emptyText = (TextView) view.findViewById(R.id.empty_text_view); mCreatePlaylistButton = (Button) view.findViewById(R.id.create_playlist); mEmptyStateLayout = (RelativeLayout) view.findViewById(R.id.empty_state); mCreatePlaylistButton.setTypeface(TypefaceHelper.getTypeface(mContext, TypefaceHelper.FUTURA_BOLD)); emptyText.setTypeface(TypefaceHelper.getTypeface(mContext, TypefaceHelper.FUTURA_BOLD)); mCreatePlaylistButton.setOnClickListener(v -> { PlaylistDialog playlistDialog = new PlaylistDialog(); playlistDialog.show(getActivity().getSupportFragmentManager(), "FRAGMENT_TAG"); }); mFastScroller.setRecyclerView(mRecyclerView); mAdapter = new PlaylistAdapter(this); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addOnScrollListener(new HidingScrollListener() { @Override public void onHide() { mOnScrolledListener.onScrolledUp(); } @Override public void onShow() { mOnScrolledListener.onScrolledDown(); } }); return view; }
Example 17
Source File: TypefaceUtil.java From storage-chooser with Mozilla Public License 2.0 | 4 votes |
public static void setTypefaceBold(Context context, Button button) { mNunitoTypeFace = Typeface.createFromAsset(context.getAssets(), "fonts/NunitoSans-Bold.ttf"); button.setTypeface(mNunitoTypeFace); }
Example 18
Source File: GameOverActivity.java From ColorPhun with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game_over); gameOverText = (TextView) findViewById(R.id.game_over); TextView levelIndicator = (TextView) findViewById(R.id.level_indicator); pointsBox = (TextView) findViewById(R.id.points_box); TextView bestLabel = (TextView) findViewById(R.id.best_label); TextView bestBox = (TextView) findViewById(R.id.best_box); highScoreText = (TextView) findViewById(R.id.highscore_txt); Button replayBtn = (Button) findViewById(R.id.replay_btn); // setting up typeface Typeface avenir_black = Typeface.createFromAsset(getAssets(), "fonts/avenir_black.ttf"); Typeface avenir_book = Typeface.createFromAsset(getAssets(), "fonts/avenir_book.ttf"); gameOverText.setTypeface(avenir_black); levelIndicator.setTypeface(avenir_book); pointsBox.setTypeface(avenir_black); bestBox.setTypeface(avenir_black); bestLabel.setTypeface(avenir_book); replayBtn.setTypeface(avenir_book); highScoreText.setTypeface(avenir_black); // disallow auto sign-in on this screen getGameHelper().setMaxAutoSignInAttempts(0); // set a simple game counter in shared pref sharedPreferences = this.getSharedPreferences( getString(R.string.preference_file_key), Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); int timesPlayed = sharedPreferences.getInt("TIMESPLAYED", 0); editor.putInt("TIMESPLAYED", timesPlayed + 1); editor.apply(); // get data Bundle bundle = getIntent().getExtras(); points = bundle.getInt("points"); level = bundle.getInt("level"); best = bundle.getInt("best"); newScore = bundle.getBoolean("newScore"); mode = MainGameActivity.GameMode.valueOf(bundle.getString("gameMode")); // set data pointsBox.setText(String.format("%03d", points)); bestBox.setText(String.format("%03d", best)); levelIndicator.setText("Level " + Integer.toString(level)); // show high score if (newScore) { highScoreText.setVisibility(View.VISIBLE); } else { highScoreText.setVisibility(View.INVISIBLE); } }
Example 19
Source File: UpdatesActivity.java From Yahala-Messenger with MIT License | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (fragmentView == null) { /*searching = false; searchWas = false;*/ // NotificationCenter.getInstance().addObserver(this,MessagesController.dialogDidLoaded); fragmentView = inflater.inflate(R.layout.updates, container, false); TextView welcome = (TextView) fragmentView.findViewById(R.id.welcome); TextView updateStatus = (TextView) fragmentView.findViewById(R.id.updateStatus); final EditText statusText = (EditText) fragmentView.findViewById(R.id.status_text); Button updateButton = (Button) fragmentView.findViewById(R.id.update_button); Typeface typefaceR = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(), "fonts/Roboto-Regular.ttf"); Typeface typefaceL = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(), "fonts/Roboto-Light.ttf"); welcome.setTypeface(typefaceR); updateStatus.setTypeface(typefaceL); updateButton.setTypeface(typefaceL); statusText.setTypeface(typefaceL); try { statusText.setText(UserConfig.clientUserStatus); } catch (Exception e) { e.printStackTrace(); } updateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { FileLog.e("Test", "onClick"); UserConfig.clientUserStatus = statusText.getText().toString(); UserConfig.saveConfig(false); } }); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } return fragmentView; }
Example 20
Source File: GDPRViewManager.java From GDPRDialog with Apache License 2.0 | 4 votes |
private void initButtons(Activity activity, Button btAgree, Button btDisagree, Button btNoConsentAtAll) { if (mSetup.hasPaidVersion()) { if (!mSetup.allowNonPersonalisedForPaidVersion()) { btDisagree.setText(R.string.gdpr_dialog_disagree_buy_app); } else { btNoConsentAtAll.setText(R.string.gdpr_dialog_disagree_buy_app); } } boolean hideAdsInfo = !mSetup.containsAdNetwork(); if (mSetup.hasPaidVersion()) { if (!mSetup.allowNonPersonalisedForPaidVersion()) { btDisagree.setText(R.string.gdpr_dialog_disagree_buy_app); hideAdsInfo = true; } } if (!hideAdsInfo) { // upper case + bold button style is removed and handled manually String textButton = activity.getString(R.string.gdpr_dialog_disagree_no_thanks).toUpperCase() + "\n"; String textInfo = activity.getString(R.string.gdpr_dialog_disagree_info); SpannableString spannableText = new SpannableString(textButton + textInfo); spannableText.setSpan(new StyleSpan(Typeface.BOLD), 0, textButton.length(), 0); spannableText.setSpan(new RelativeSizeSpan(0.8f), textButton.length(), spannableText.length(), 0); spannableText.setSpan(new ForegroundColorSpan(btDisagree.getTextColors().getDefaultColor()), textButton.length(), spannableText.length(), 0); btDisagree.setAllCaps(false); btDisagree.setTypeface(Typeface.DEFAULT); btDisagree.setText(spannableText); } // int textColorPrimary = GDPRUtils.getThemeColor(context, android.R.attr.textColorPrimary); // boolean textColorIsDark = GDPRUtils.isColorDark(textColorPrimary); // // int btBackgorundColor = textColorIsDark ? Color.DKGRAY : Color.WHITE; // int btForegorundColor = textColorIsDark ? Color.WHITE : Color.BLACK; // // btDisagree.getBackground().setColorFilter(btForegorundColor, PorterDuff.Mode.MULTIPLY); // btNoConsentAtAll.getBackground().setColorFilter(btForegorundColor, PorterDuff.Mode.MULTIPLY); // btDisagree.setTextColor(btBackgorundColor); // btNoConsentAtAll.setTextColor(btBackgorundColor); }