How to get “?android:attr/actionBarSize” with Compatibility Library

前端 未结 2 1285
长情又很酷
长情又很酷 2021-02-15 17:56

I\'m trying to use Fragments and ActionBar in a Android 2.2 project. There is some error when using \"?android:attr/actionBarSize\", how to get and set that value correctly?

2条回答
  •  终归单人心
    2021-02-15 18:35

    You should just use:

    android:layout_marginTop="?attr/actionBarSize"
    

    See http://developer.android.com/training/basics/actionbar/overlaying.html

    "...The one with the android: prefix is for versions of Android that include the style in the platform and the one without the prefix is for older versions that read the style from the Support Library..."

    For me replacing

    android:layout_marginTop="?android:attr/actionBarSize" 
    

    with

    android:layout_marginTop="?attr/actionBarSize" 
    

    helped to launch app on Android 2.2 and Android 4.3 without any issues.

提交回复
热议问题