New Theme.AppCompat ActionBar Height
There is no workaround. If you are using ?android:attr/actionBarSize
android will look for the value in the plattform you are using. The result will be 48dp if you are using Android version below 5.0, obviously.
Since you are using a library appcompat-v7
in your project, you should use ?actionBarSize
. This will return 56dp as expected because the system will look for a value in your project that has a BarSize action defined due to the appcompat library.
If you'd like to try it yourself, here's a little code snippet to test the described behavior:
int[] textSizeAttr = new int[] { android.R.attr.actionBarSize, R.attr.actionBarSize };
TypedArray a = obtainStyledAttributes(new TypedValue().data, textSizeAttr);
float heightHolo = a.getDimension(0, -1);
float heightMaterial = a.getDimension(1, -1);
Log.d("DEBUG", "Height android.R.attr.: " + heightHolo + "");
Log.d("DEBUG", "Height R.attr.: " + heightMaterial + "");
Note. ... This will return the size in pixels. As an example on my Nexus 5, which is currently running 4.4, it returns 144px (48dp) for android.R.attr.actionBarSize and 168px (56dp) for R.attr.actionBarSize.
source to share