相关疑难解决方法(0)

如何使用兼容性库获取"?android:attr/actionBarSize"

我正在尝试在Android 2.2项目中使用Fragments和ActionBar.使用"?android:attr/actionBarSize"时有一些错误,如何正确获取和设置该值?

例:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/frags">

    <fragment class="com.example.android.hcgallery.TitlesFragment"
            android:id="@+id/frag_title"
            android:visibility="gone"
            android:layout_marginTop="?android:attr/actionBarSize"
            android:layout_width="@dimen/titles_size"
            android:layout_height="match_parent" />

    <fragment class="com.example.android.hcgallery.ContentFragment"
            android:id="@+id/frag_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

错误:找不到与给定名称匹配的资源(在'layout_marginTop'中,值为'?android:attr/actionBarSize').

android android-layout android-compatibility

8
推荐指数
2
解决办法
1万
查看次数