0

我在我的應用程序使用RecylerViewCardView,這我在build.gradle文件的依賴性:我應該在依賴項中添加recyclerView和CardView嗎?

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.2.1' 
    compile 'com.android.support:design:23.2.1' 
    compile 'co.ronash.pushe:android-lib:0.9.1'   
    compile('com.mikepenz:materialdrawer:[email protected]') { 
     transitive = true 
    }   
    compile('com.mikepenz:crossfadedrawerlayout:[email protected]') 
    compile 'com.mikepenz:google-material-typeface:[email protected]' 
    compile 'com.mikepenz:fontawesome-typeface:[email protected]' 
    compile 'com.mikepenz:octicons-typeface:[email protected]' 

    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+' 
    compile 'com.github.bluejamesbond:textjustify-android:2.1.1' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.github.jd-alexander:LikeButton:0.2.0' 
    compile project(':material_rey') 
    } 

我的應用程序在奇巧正常工作。我應該將這些依賴關係添加到我的build.gradle嗎?有什麼不同?

compile 'com.android.support:cardview-v7:23.2.1' 
compile 'com.android.support:recyclerview-v7:23.2.1' 

我使用Android Studio 2.0。當我用android 5.1.1(棒棒糖)在SAMSUNG A5上運行我的應用時,我的RecyclerView不滾動,我的CardView沒有陰影和角落。我嘗試在SO中建議的解決方案,例如添加card_view:cardUseCompatPadding="true"或增加保證金。即使更改xmlns:card_view="http://schemas.android.com/apk/res-auto"xmlns:card_view="http://schemas.android.com/tools"也不起作用。
這些問題是否與依賴關係有關?

+0

真的,我有另一個外部庫在我的依賴如畢加索和材料抽屜。 – Mneckoee

+1

是的。您必須將它們添加爲庫依賴項。 –

+0

但是,當我不添加它們時,我的應用程序運行成功。爲什麼? – Mneckoee

回答

1

com.android.support:design:23.2.1包括其中的RecyclerView。雖然cardView沒有在鏈接中提及,但如果您沒有發現任何錯誤,並且cardview正在渲染,那麼它也包含在內。因此,您不需要將這些添加到依賴關係中。

如果其行在屏幕中合適,RecyclerView將不會滾動。你可以爲這些提出單獨的SO問題。

+0

你能解釋更多關於recyclerView行嗎?它滾動kitkat,但不在A5 – Mneckoee

+0

可以說,你有一個recyclerview中的5行/項目,他們的尺寸是這樣,他們適合你的設備的屏幕。那麼不需要滾動,因此它不會滾動。所以你的A5屏幕可能能夠容納recyclerview的所有項目 – suku

+0

:)。沒有。我的列表有足夠的滾動項目,有些項目沒有完全顯示意味着需要滾動。有一種奇怪的行爲:如果我在屏幕上向上移動手指(向下滾動),回收站不會顯示任何變化,但是如果我去其他活動並回來,我會看到回收站向下滾動! – Mneckoee

相關問題