How to set a custom font to the title in toolbar android

Since android.support.v7.appcompat 24.2 Toolbar has method setTitleTextAppearance and you can set its font without external textview. create new style in styles.xml <style name=”RobotoBoldTextAppearance”> <item name=”android:fontFamily”>@font/roboto_condensed_bold</item> </style> and use it mToolbar.setTitleTextAppearance(this, R.style.RobotoBoldTextAppearance);

setSupportActionBar toolbar cannot be applied to (android.widget.Toolbar) error

In your Activity.java import android.support.v7.widget.Toolbar instead of android.widget.Toolbar: import android.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.support.v7.widget.Toolbar; public class rutaActivity extends AppCompactActivity { private Toolbar toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ruta); getSupportActionBar().hide();//Ocultar ActivityBar anterior toolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(toolbar); //NO PROBLEM !!!! Update: If you are using androidx, replace … Read more

How can I align Android Toolbar menu/icons to the left like in Google Maps app?

After some struggling and digging in Android Toolbar code I managed to make it work. Basically, the idea is to add a new android.support.v7.widget.ActionMenuView as child of the Toolbar, set its gravity to top|start, and then add the menu to that action menu view in your Activity. Here is the code: my_toolbar.xml <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” … Read more

How to fix getActionBar method may produce java.lang.NullPointerException

Actually Android Studio isn’t showing you an “error message”, it’s just a warning. Some answers propose the use of an assertion, Dalvik runtime has assertion turned off by default, so you have to actually turn it on for it to actually do something. In this case (assertion is turned off), what you’re essentially doing is … Read more

How to change CollapsingToolbarLayout typeface and size?

Update Before we dive into the code let’s first decide the textSize for our CollapsingToolbarLayout. Google published a website called material.io, this website also explains the best way on how to deal with Typography. The article mentioned about “Heading” category which also explains the recommended font size to use in sp. Although the article never … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)