Android:支持功能未出现在android L中 [英] Android: support features don't appear in android L

查看:99
本文介绍了Android:支持功能未出现在android L中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Android Studio 2.0。我使用了RecyclerView和CardView,它们可以在kitkat上正确渲染,但是当应用程序在具有Android 5.1.1(棒棒糖)的SAMSUNG A5上运行时,RecyclerView无法滚动,并且我的CardView没有高度和

我尝试了SO中建议的解决方案,例如添加

card_view:cardUseCompatPadding = true 并增加边距。 br>
甚至更改了

xmlns:card_view = http://schemas.android.com/apk/res-auto < br>


xmlns:card_view = http://schemas.android.com/tools

但是这些没有用

I use Android Studio 2.0 . I have used RecyclerView and CardView which render properly on kitkat but when the app is run on SAMSUNG A5 with android 5.1.1 (lollipop) the RecyclerView doesn't scroll and my CardView doesn't have elevation and corner.
I tried solutions suggested in SO such as adding
card_view:cardUseCompatPadding="true" and adding margin.
Even changed
xmlns:card_view="http://schemas.android.com/apk/res-auto"
to
xmlns:card_view="http://schemas.android.com/tools"
But these didn't work

这是我的RecyclerView:

This is my RecyclerView:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/grid_cards_recyclerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    android:layoutDirection="rtl"
    android:padding="2dp"
    android:background="#e0e0e0"

    />

RecyclerView GridRecyclerView = (RecyclerView) getActivity().findViewById(R.id.grid_cards_recyclerview);
        GridLayoutManager gll = new GridLayoutManager(getActivity(), 2);

        GridRecyclerView.setLayoutManager(gll);
        GridAdapter gridAdapter = new GridAdapter(getActivity(), mylist);
        GridRecyclerView.setAdapter(gridAdapter);

这是一个奇怪的行为:如果我在屏幕上向上移动手指(向下滚动),recyclerview不会没有显示任何变化,但是如果我去参加另一个活动然后回来,我看到recyclerview向下滚动了!!您如何解释这种行为? Recyclerview可以识别滚动运动,但不显示其反应,也不会更新其视图!

this is a strange behavior: if I move up my finger on screen (scroll down), recyclerview doesn't show any change but if I go to another activity and come back I see the recyclerview has scrolled down!! How do you explain this behavior?! Recyclerview recognizes scroll motion but doesn't show its reaction and doesn't update its view!

推荐答案

我解决了RecyclerView问题。 我进行了很多搜索。我将代码写在一个片段中,并对其进行预览,我使用了

I solved RecyclerView issue. I searched a lot. I write my code in a fragment and for previewing them I used

fragmentTransaction.add(R.id.fragment_main,
                fragment);

所以在棒棒糖中,我的片段位于前一个片段的后面,无法处理触摸,所以现在我使用

so in lollipop my fragment went behind the previous fragment and didn't handle touches so now I use

fragmentTransaction.replace(R.id.fragment_main,
                    fragment);

现在正在滚动 recyclerView

对于阴影,我使用了 card_view:cardUseCompatPadding = true ,但由于我设置了而没有用清单中的android:hardwareAccelerated 为false。使其成为现实可以解决问题。

For shadow I used card_view:cardUseCompatPadding="true" but didn't work because I set android:hardwareAccelerated in Manifest to false. Making it true solved the problem.

这篇关于Android:支持功能未出现在android L中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆