List of usage examples for android.graphics Typeface createFromAsset
public static Typeface createFromAsset(AssetManager mgr, String path)
From source file:com.mindgames.dailylaw.external.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 ww w. ja v a 2 s. c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); Typeface tf1 = Typeface.createFromAsset(context.getAssets(), "fonts/proxima_nova.otf"); textView.setTypeface(tf1); 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); return textView; }
From source file:iit.iitrc.rahil.cognizance_2016.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 ww. j a va2s .c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(14); textView.setTypeface(Typeface.createFromAsset(context.getApplicationContext().getAssets(), String.format("fonts/%s", "Lato-Bold.ttf"))); 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(false); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:bucci.dev.freestyle.TimerActivity.java
private void initButtons() { playButton = (ImageView) findViewById(R.id.start_pause_button); playButton.setTag(PLAY_BUTTON_START_STATE); timerTextView = (TextView) findViewById(R.id.timer_text); Typeface digital_font = Typeface.createFromAsset(getAssets(), DIGITAL_CLOCK_FONT); timerTextView.setTypeface(digital_font); musicTextView = (TextView) findViewById(R.id.music); }
From source file:com.near.chimerarevo.fragments.ProductFragment.java
private void addTitle(String text) { TextView title = new TextView(getActivity()); title.setBackgroundColor(getResources().getColor(R.color.prod_title_color)); title.setTextColor(getResources().getColor(android.R.color.white)); title.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "roboto_light.ttf")); title.setTextSize(22);// w w w . jav a2 s . c o m title.setPadding(15, 10, 15, 10); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); title.setLayoutParams(params); title.setText(text); View div = new View(getActivity()); div.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 2)); div.setBackgroundColor(getResources().getColor(R.color.prod_title_color)); lay.addView(title); lay.addView(div); }
From source file:com.traderacademy.supprot.view.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 ww .j a v a 2 s. co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); Typeface typeFace = Typeface.createFromAsset(context.getAssets(), "fonts/NORMAL_GBK.TTF"); textView.setTypeface(typeFace); 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); return textView; }
From source file:il.co.togetthere.ScreenSlideActivity.java
@SuppressLint("InlinedApi") @Override// w w w . java 2s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen_slide); // Start to import data from DB mThread.delegate = this; mCurr = -1; /** * View Initialization **/ // Hide the status bar. //View decorView = getWindow().getDecorView(); //int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; //decorView.setSystemUiVisibility(uiOptions); // Remember that you should never show the action bar if the // status bar is hidden, so hide that too if necessary. android.app.ActionBar actionBar = getActionBar(); actionBar.hide(); /** * Set Profile Picture **/ ProfilePictureView profilePictureView = (ProfilePictureView) findViewById( R.id.button_show_user_details_slide); profilePictureView.setProfileId(LoginActivity.user.getID()); profilePictureView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent infoIntent = new Intent(ScreenSlideActivity.this, UserInfoActivity.class); ScreenSlideActivity.this.startActivity(infoIntent); } }); /** * Get Values **/ Intent inIntent = getIntent(); setmServiceProviderType(inIntent.getStringExtra("TYPE_EXTRA")); if (getmServiceProviderType() != null && getmServiceProviderType().equals("help")) { mThread.execute(DynamoDBManagerType.GET_TASKS.toString()); } else { mThread.execute(DynamoDBManagerType.GET_PROVIDER.toString(), ServiceProvider.stringToEnum(getmServiceProviderType()).toString()); } /** * Set Lower Bar Functions */ ((LinearLayout) findViewById(R.id.button_add_new_location)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent addNewIntent; if (getmServiceProviderType().equals("help")) { addNewIntent = new Intent(ScreenSlideActivity.this, AddNewTaskActivity.class); ScreenSlideActivity.this.startActivity(addNewIntent); } else { addNewIntent = new Intent(ScreenSlideActivity.this, AddSPActivity.class); ScreenSlideActivity.this.startActivity(addNewIntent); } } }); // TODO "Rank" button Handler LinearLayout rankButton = (LinearLayout) findViewById(R.id.button_rank); if (getmServiceProviderType().equals("help")) { rankButton.setVisibility(View.INVISIBLE); } else { rankButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Rank Dialog } }); } LinearLayout editButton = (LinearLayout) findViewById(R.id.button_edit); if (getmServiceProviderType().equals("help")) { editButton.setVisibility(View.INVISIBLE); } else { editButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent editIntent = null; editIntent = new Intent(ScreenSlideActivity.this, EditActivity.class); editIntent.putExtra("SP_NUMBER", mCurr); ScreenSlideActivity.this.startActivity(editIntent); // TODO - update SP when editing is finished } }); } // Titles TextView titleRank = ((TextView) findViewById(R.id.button_rank_title)); TextView titleAdd = ((TextView) findViewById(R.id.button_add_new_location_title)); TextView titleEdit = ((TextView) findViewById(R.id.button_edit_title)); // Define Font Typeface font = Typeface.createFromAsset(getAssets(), "fonts/GOTHIC.TTF"); titleRank.setTypeface(font); titleAdd.setTypeface(font); titleEdit.setTypeface(font); }
From source file:chaitanya.im.searchforreddit.LauncherActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get and set theme from shared preferences sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); theme = sharedPref.getInt(getString(R.string.style_pref_key), 0); donate = sharedPref.getInt(getString(R.string.donate_check), 0); UtilMethods.onActivityCreateSetTheme(this, theme, SOURCE); mServiceConn = new ServiceConnection() { @Override//w ww .j a v a2 s .c o m public void onServiceDisconnected(ComponentName name) { mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { mService = IInAppBillingService.Stub.asInterface(service); Log.d(TAG, "Service Connected"); getPrices(); } }; //ComponentName myService = startService(new Intent(this, LauncherActivity.class)); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); // IAP stuff skuList = new ArrayList<>(); skuList.add("donate"); skuList.add("donate2"); skuList.add("donate3"); querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); setContentView(R.layout.activity_launcher); // Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); fontAwesome = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf"); dialog = new GenericAlertDialog(); dialog.setFontAwesome(fontAwesome); Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar); LinearLayout searchBox = (LinearLayout) findViewById(R.id.search_box); searchOptions = (LinearLayout) findViewById(R.id.search_options); launcherRefresh = (SwipeRefreshLayout) findViewById(R.id.launcher_refresh); searchEditText = (EditText) findViewById(R.id.search_edit_text); clearSearchBoxButton = (ImageButton) findViewById(R.id.clearSearchBox); //filterButton = (Button) findViewById(R.id.filter_button); sortButton = (Button) findViewById(R.id.sort_button); timeButton = (Button) findViewById(R.id.time_button); coordinatorLayout = (CoordinatorLayout) findViewById(R.id.launcher_coordinatorlayout); searchOptions.post(new Runnable() { @Override public void run() { searchOptionsCenter = searchOptions.getWidth() / 2; if (searchOptions.getVisibility() != View.VISIBLE) { UtilMethods.revealView(searchOptions, searchOptionsCenter, 0); } } }); setSupportActionBar(toolbar); searchEditText.setOnKeyListener(onKeyListener); searchEditText.setOnTouchListener(searchEditTextTouchListener); sortButton.setOnLongClickListener(buttonLongClick); timeButton.setOnLongClickListener(buttonLongClick); //filterButton.setOnLongClickListener(buttonLongClick); rvResults = (RecyclerView) findViewById(R.id.result_view_launcher); ResultsAdapter adapter = new ResultsAdapter(resultList, this); rvResults.setAdapter(adapter); rvResults.setLayoutManager(new LinearLayoutManager(this)); rvResults.addItemDecoration(new SimpleDividerItemDecoration(this, theme)); //rvResults.setRecyclerListener(recyclerListener); urlSearch = new UrlSearch(BASE_URL, this, 1, adapter); // dp -> px : http://stackoverflow.com/a/9563438/1055475 Resources resources = getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); float px = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { toolbar.setElevation(px * 4); searchBox.setElevation(px * 3); } else { findViewById(R.id.shadow).setVisibility(View.VISIBLE); findViewById(R.id.shadow2).setVisibility(View.VISIBLE); } Log.d(TAG, "OnCreate"); Log.d(TAG, "searchEditText - " + searchEditText.getText().toString()); launcherRefresh.setOnRefreshListener(refreshListener); launcherRefresh.setColorSchemeResources(R.color.blue_tint, R.color.reddit_orange, R.color.material_light_black); UtilMethods.getLocation(); Intent intent = getIntent(); receiveIntent(intent); }
From source file:com.lcl.thumbweather.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.e("-LCL-", "MainActivity:onCreated."); // Initialize the associated SharedPreferences file with default values PreferenceManager.setDefaultValues(this, R.xml.prefs, false); darkTheme = false;//w w w .jav a 2s .c om SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean("darkTheme", false)) { setTheme(R.style.AppTheme_NoActionBar_Dark); darkTheme = true; } // ? activity super.onCreate(savedInstanceState); setContentView(R.layout.activity_scrolling); appView = findViewById(R.id.viewApp); progressDialog = new ProgressDialog(MainActivity.this); // toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // toolbar.setTitle(""); setSupportActionBar(toolbar); //Logo toolbar.setLogo(R.mipmap.umbrella_white); if (darkTheme) { toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay_Dark); } // ? textboxes todayTemperature = (TextView) findViewById(R.id.todayTemperature); todayDescription = (TextView) findViewById(R.id.todayDescription); todayWind = (TextView) findViewById(R.id.todayWind); todayPressure = (TextView) findViewById(R.id.todayPressure); todayHumidity = (TextView) findViewById(R.id.todayHumidity); todaySunrise = (TextView) findViewById(R.id.todaySunrise); todaySunset = (TextView) findViewById(R.id.todaySunset); todayIcon = (TextView) findViewById(R.id.todayIcon); cityIs = (TextView) findViewById(R.id.city); weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf"); todayIcon.setTypeface(weatherFont); // ? viewPager viewPager = (ViewPager) findViewById(R.id.viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs); destroyed = false; initMappings(); // ? preloadWeather(); // AlarmReceiver.setRecurringAlarm(this); }
From source file:com.scigames.registration.LoginActivity.java
/** Called with the activity is first created. */ @Override/*www.j a v a 2s .com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION ); // View v = findViewById(R.layout.login_page); // v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); //Window w = this.getWindow(); // in Activity's onCreate() for instance //w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, // WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.login_page); Log.d(TAG, "super.OnCreate"); // Inflate our UI from its XML layout description. // Intent i = getIntent(); // if (i.hasExtra("token")){ // setContentView(R.layout.login_page); // } else { // setContentView(R.layout.no_device); // } lastName = (EditText) findViewById(R.id.last_name); password = (EditText) findViewById(R.id.password); classId = (EditText) findViewById(R.id.class_id); firstName = (EditText) findViewById(R.id.first_name); /* to hide the keyboard on launch, then open when tap in firstname field */ //firstName.setActivated(false); //firstName.setSelected(false); firstName.setCursorVisible(false); firstName.setInputType(InputType.TYPE_NULL); firstName.setOnTouchListener(new View.OnTouchListener() { //@Override public boolean onTouch(View v, MotionEvent event) { firstName.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); firstName .setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); firstName.setCursorVisible(true); firstName.onTouchEvent(event); // call native handler return true; // consume touch even } }); //for faster testing: // firstName.setText("joseph7"); // lastName.setText("christopher"); // password.setText("qweasd"); // classId.setText("66"); // // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.login_button)).setOnClickListener(mLogInListener); ((Button) findViewById(R.id.register)).setOnClickListener(mRegisterListener); //set listener task.setOnResultsListener(this); alertDialog = new AlertDialog.Builder(LoginActivity.this).create(); // Setting Dialog Title alertDialog.setTitle("Login Failed"); // Setting Dialog Message alertDialog.setMessage("Welcome to AndroidHive.info"); // Setting Icon to Dialog //alertDialog.setIcon(R.drawable.tick); alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Toast.makeText(getApplicationContext(), "Check your login info!", Toast.LENGTH_SHORT).show(); } }); Typeface ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf"); Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf"); Typeface Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf"); Typeface Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf"); // TextView welcome = (TextView)findViewById(R.id.welcome); TextView notascigamersentence = (TextView) findViewById(R.id.notascigamersentence); // setTextViewFont(ExistenceLightOtf, welcome); setTextViewFont(Museo500Regular, notascigamersentence); setEditTextFont(Museo500Regular, firstName, lastName, password, classId); login = (Button) findViewById(R.id.login_button); register = (Button) findViewById(R.id.register); /* out for now */ setButtonFont(ExistenceLightOtf, login, register); setButtonFont(Museo500Regular, register); // if (getIntent().getBooleanExtra("EXIT", false)) { // finish(); // } }
From source file:com.scigames.registration.ProfileActivity.java
/** Called with the activity is first created. */ @Override/*from www . jav a 2 s.co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); Log.d(TAG, "super.OnCreate"); Intent i = getIntent(); Log.d(TAG, "getIntent"); firstNameIn = i.getStringExtra("fName"); lastNameIn = i.getStringExtra("lName"); // passwordIn = i.getStringExtra("password"); // massIn = i.getStringExtra("mass"); // emailIn = i.getStringExtra("email"); // classIdIn = i.getStringExtra("classId"); studentIdIn = i.getStringExtra("studentId"); visitIdIn = i.getStringExtra("visitId"); // rfidIn = i.getStringExtra("rfid"); photoUrl = i.getStringExtra("photoUrl"); photoUrl = "http://db.scigam.es/" + photoUrl; // slideLevel = i.getStringExtra("slideLevel"); // cartLevel = i.getStringExtra("cartLevel"); Log.d(TAG, "...getStringExtra"); // Inflate our UI from its XML layout description. setContentView(R.layout.profile_page); Log.d(TAG, "...setContentView"); //display name and profile info Resources res = getResources(); greets = (TextView) findViewById(R.id.student_name); greets.setText(String.format(res.getString(R.string.profile_name), firstNameIn, lastNameIn)); setTextViewFont(Museo700Regular, greets); //schoolname = (TextView)findViewById(R.id.school_name); //schoolname.setText(String.format(res.getString(R.string.profile_school_name), "from DB")); teachername = (TextView) findViewById(R.id.teacher_name); //teachername.setText(String.format(res.getString(R.string.profile_teacher_name), "from DB")); classname = (TextView) findViewById(R.id.class_name); classid = (TextView) findViewById(R.id.class_id); //classid.setText(String.format(res.getString(R.string.profile_classid), classIdIn)); mpass = (TextView) findViewById(R.id.password); //mpass.setText(String.format(res.getString(R.string.profile_password), passwordIn)); Log.d(TAG, "...Profile Info"); ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf"); Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf"); Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf"); Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf"); // TextView welcome = (TextView)findViewById(R.id.welcome); // TextView notascigamersentence = (TextView)findViewById(R.id.notascigamersentence); // Hook up button presses to the appropriate event handler. //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); //((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener); Log.d(TAG, "...instantiateButtons"); Done = (Button) findViewById(R.id.done); Done.setOnClickListener(mDone); setButtonFont(ExistenceLightOtf, Done); alertDialog = new AlertDialog.Builder(ProfileActivity.this).create(); // Setting Dialog Title alertDialog.setTitle("alert title"); // Setting Dialog Message alertDialog.setMessage("alert message"); // Setting Icon to Dialog //alertDialog.setIcon(R.drawable.tick); alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed //Toast.makeText(getApplicationContext(), "Check your login info!", Toast.LENGTH_SHORT).show(); } }); //set listener task.setOnResultsListener(this); //push picture back.-- photo task.cancel(true); //create a new async task for every time you hit login (each can only run once ever) task = new SciGamesHttpPoster(ProfileActivity.this, "http://db.scigam.es/pull/return_profile.php"); //set listener task.setOnResultsListener(ProfileActivity.this); //prepare key value pairs to send String[] keyVals = { "student_id", studentIdIn, "visit_id", visitIdIn }; //create AsyncTask, then execute @SuppressWarnings("unused") AsyncTask<String, Void, JSONObject> serverResponse = null; serverResponse = task.execute(keyVals); Log.d(TAG, "...task.execute(keyVals)"); }