小编vj9*_*vj9的帖子

RecyclerView中的CardView具有额外的利润

我在RecyclerView中使用CardView作为元素.这样做时,android会自动在cardView和屏幕之间以及不同的cardView之间生成边距.

<android.support.v7.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/galleryCardBGColor"
app:cardCornerRadius="2dp" >

<android.support.v7.widget.RecyclerView
    android:id="@+id/my_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical" />
Run Code Online (Sandbox Code Playgroud)

我按照链接中的说明将它们集成到我的项目中: using-recyclerview-and-cardview-in-eclipse-adt

我之前使用过linearlayout作为list元素:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)

这工作得非常好,列表元素之间没有任何边距.我现在刚刚在cardView中放置了线性布局,这导致了额外的边距.

原因是我想为这些元素提供精确的边距,而我现在提供的任何边距都会被添加到这个预先存在的边距.我已经尝试向cardView元素提供零/负填充/边距,但这些都不起作用.

任何想法,我可以删除这些边距或以其他方式确切地知道添加了多少保证金.

android eclipse-adt android-cardview android-recyclerview

33
推荐指数
5
解决办法
4万
查看次数

在Swift上基于流的JSON解析

如何在Swift上解析作为流下载的JSON?流每次都会提供不完整的JSON数据.这是因为我必须下载数据MB,其主要组件是一长串对象,我不希望用户等到我获得完整的数据.流式传输时是否可以按顺序解析JSON数据?基本上,像Jackson在Android上允许的东西,或者是Swift的YAJLiOS Parser实现

parsing json stream ios swift

12
推荐指数
1
解决办法
1250
查看次数

在Samsung S4上打开GL错误配置错误

我在Samsung S4上收到以下错误

10-21 16:25:44.100: E/AndroidRuntime(29778): FATAL EXCEPTION: GLThread 11320
10-21 16:25:44.100: E/AndroidRuntime(29778): Process: <bundle ID>, PID: 29778
10-21 16:25:44.100: E/AndroidRuntime(29778): java.lang.RuntimeException: createContext failed: EGL_BAD_CONFIG
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1201)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1192)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1042)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1409)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
Run Code Online (Sandbox Code Playgroud)

错误是因为:

this.setEGLContextFactory(new MyDefaultContextFactory());
this.setEGLConfigChooser(GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE,
        GL_DEPTH_SIZE, 0);//<-this line
this.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR
        | GLSurfaceView.DEBUG_LOG_GL_CALLS);
this.setPreserveEGLContextOnPause(true);
this.setEGLContextClientVersion(2);
Run Code Online (Sandbox Code Playgroud)

通过的配置是:8,8,8,8,24

尽管在最后移动上面的行.这是什么原因?

PS:在任何一种情况下,代码在Nexus5或MotoG上都能正常工作.所有运行Kitkat 4.4.2的设备

android opengl-es

4
推荐指数
1
解决办法
1392
查看次数