转移到Android Design Support v23.0.0后,Android Studio无法构建一个使用Android Design Support v22.2.1构建的项目:
找不到与给定名称匹配的资源(在'tabMaxWidth'处,值为'@ dimen/tab_max_width').
这是怎么回事?
使用具有以下视图层次结构的设计支持库22.2.1:
<DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
app:tabGravity="fill"
app:tabMode="scrollable" />
</AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
<!-- Fragments replaced here -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CustomDashboardView
android:layout_width="match_parent"
android:layout_height="120dp" />
<ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Tab Fragments go here -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CustomEmptyErrorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ViewPager>
</LinearLayout>
</FrameLayout>
</CoordinatorLayout>
<NavigationView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:fitsSystemWindows="true" />
</DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我遇到了一个问题,其中RecyclerView的高度大于应包含该可见区域的可见区域,因此RecyclerView看起来像在屏幕外绘制,并且不可能将RecyclerView中的最后一项滚动到完整视图。关于工具栏和TabLayout也没有任何变化(尽管layout_behaviour应用于FrameLayout)。
我曾将其报告为错误,但是ol'Banesy表示这已按预期进行。如果是这种情况,我如何避免这种预期的行为,而使用RecyclerView,它尊重layout_height =“ match_parent”并在可见屏幕内绘制其项目?https://code.google.com/p/android/issues/detail?id=182391
更新:现在有了Design Support …
android android-recyclerview androiddesignsupport android-coordinatorlayout
所以我一直在寻找一种方法来改变我的菜单弹出背景颜色,但我现在真的没有想法......首先,这是我的工具栏:
<android.support.v7.widget.Toolbar
android:id="@+id/main_actionbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="2dp"
app:elevation="2dp"
app:theme="@style/MainActionBar"
app:popupTheme="@style/MainActionBar.Popup"/>
Run Code Online (Sandbox Code Playgroud)
以及我在没有任何背景变化的情况下应用的 2 个主题:
<style name="MainActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/primary</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
</style>
<style name="MainActionBar.Popup" parent="Widget.AppCompat.PopupMenu">
<item name="android:textColor">@color/primary_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这使我的项目背景颜色看起来是蓝色的,因为我将应用程序的主要和次要颜色设置为蓝色。
我发现将项目菜单颜色更改为白色的一种解决方案是在 MainActionBar.Popup 中将 android:background 设置为白色,如下所示:
Widget.AppCompat.PopupMenu 与 android:background 设置为 @android:color/white
虽然这确实将背景颜色更改为白色,但它也会在动画开始之前将弹出窗口后面的框渲染为白色,这会破坏动画。
另一种选择是将 android:itemBackground 设置为白色,如下所示:
Widget.AppCompat.PopupMenu 与 android:itemBackground 设置为 @android:color/white
如您所见,动画现在看起来不错,但项目背景并非完全白色......
我也试过 android:popupBackground 但它似乎没有任何效果。
我知道这是一个经常被问到的问题,但我已经阅读了很多,所以我可能只是没有看到明显的错误......