android:layout_height="?attr/actionBarSize" is not working with support:design:23.0.0' library
Asked Answered
B

5

22

If I set android:layout_height="56dp", I can see the toolbar in graphical layout. But when I set like the below,

       <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/purple"
            android:gravity="center_vertical"
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">  </android.support.v7.widget.Toolbar>

toolbar is not showing in graphical layout.

Studio says that attr/actionBarSize is marked as private.

I am using

 compile 'com.android.support:appcompat-v7:23.0.0'
 compile 'com.android.support:design:23.0.0'

What could be the issue? How can i fix it! Yes, Studio is updated.

Boehmenist answered 2/9, 2015 at 11:53 Comment(4)
Seems weird. I'm on 23 as well and I don't have this issue.Beethoven
@Poss What is your Android studio version?Boehmenist
try to rempve 'attr' just write android:layout_height="?actionBarSize"...Complementary
Use ?android:attr/actionBarSizeWorriment
R
35

Use ?android:attr/actionBarSize instead of ?attr/actionBarSize

Raucous answered 7/4, 2018 at 5:32 Comment(1)
Works with Android:attrFuse
E
7

finally i did it just change your method

?attr/actionBarSize to ?android:attr/actionBarSize

Evelinevelina answered 1/5, 2018 at 11:5 Comment(0)
D
3

It seems to be a bug in Android Studio: https://code.google.com/p/android/issues/detail?id=183120

The issue should be fixed in Android Studio 1.4 Preview 3. An update of the gradle plugin is also recommended. At least Gradle plugin version 1.4-alpha2

As a workaround you can disable the Lint-check in the build.gradle:

android {
    lintOptions {
        disable 'PrivateResource'
    }
}
Daphinedaphna answered 2/9, 2015 at 12:52 Comment(3)
Did you also update your gradle-plugin as mentioned in the issue: Gradle plugin version 1.4-alpha2Daphinedaphna
Will try and let you know!!Boehmenist
Thanks. Note that in 26 support lib you have to remove this workaround to get it workDarned
I
0

What is your app theme ?

Can you try to put android:theme="@style/Theme.AppCompat.Light" in your Toolbar layout ?

Inscribe answered 2/9, 2015 at 12:37 Comment(1)
Tried, But no Luck :-)Boehmenist
B
0

It was a problem in setting the theme.

Theme Values-v21.

 <style name="AppTheme" parent="Theme.AppCompat">
        <item name="android:colorPrimary">@color/purple_medium</item>
        <item name="android:colorPrimaryDark">@color/purple</item>
        <item name="android:colorAccent">@color/iron</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:textColorHint">@color/black_lite</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:textColorSecondary">@color/white</item>
        <item name="colorControlActivated">@color/purple</item>
        <item name="colorControlHighlight">@color/purple</item>
        <item name="colorControlNormal">@color/iron</item>
        <item name="android:textColorPrimary">@color/purple</item>
        <item name="android:windowContentTransitions">true</item>
    </style>

when i selected the correct theme like here, it works fine for me!

enter image description here

Hope it helps.

Boehmenist answered 12/10, 2015 at 6:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.