小编Jac*_*ple的帖子

如何使用垂直GridLayoutManager水平居中RecyclerView项目

我有垂直RecyclerView使用GridLayoutManager.我希望每列都居中,但列始于左侧.在下图中,您可以看到我在说什么.我用丑陋的配色方案来说明列和背景.绿色是每个项目的背景RecyclerView,红色是RecyclerView自身的背景:

http://imgur.com/a/J3HtF

我正在设置:

mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
Run Code Online (Sandbox Code Playgroud)

这是column_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="120dp"
              android:layout_height="180dp"
              android:orientation="vertical"
              android:padding="4dp">

    <ImageView
        android:id="@+id/movie_column_photo"
        android:layout_width="80dp"
        android:layout_height="120dp"/>

    <TextView
        android:id="@+id/movie_column_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是recyclerview xml:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

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

android gridlayoutmanager android-recyclerview

46
推荐指数
1
解决办法
3万
查看次数

Retrofit - A/libc:致命信号11(SIGSEGV),代码1

我正在接收A/libc:致命信号11(SIGSEGV),代码1使用改造类来生成我的服务接口的实现.

我相信这是由于本机库中的空指针段错误.没有任何东西被抛出,所以我无法追踪它.最奇怪的部分是它不会发生在我的任何仿真器或物理设备(均为6.0)上,除了我的HTC恰好是6.0.1.

这是我的界面:

public interface RestApiPerson {
    @GET(QUERY_PERSON)
    Call<PersonSearchResults> getPersonSearchResult(@Query("query") String q);
}
Run Code Online (Sandbox Code Playgroud)

这是实施.崩溃发生在(Call <PersonSearchResults> call = restApi.getPersonSearchResult(query);)

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(END_POINT_PERSON)
        .addConverterFactory(GsonConverterFactory.create())
        .build();

RestApiPerson restApi = retrofit.create(RestApiPerson.class);
Call<PersonSearchResults> call = restApi.getPersonSearchResult(query);
Run Code Online (Sandbox Code Playgroud)

这是堆栈:

07-31 12:58:08.492 18310-18310/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3ad75934
07-31 12:58:08.522 18310-18310/? A/DEBUG:     r0 70fc5774  r1 12d78a00  r2 0025af14  r3 b276c070
07-31 12:58:08.522 18310-18310/? A/DEBUG:     r4 0025af14  r5 12d78a00  r6 70fc4dc4  r7 715c4a80
07-31 12:58:08.522 18310-18310/? A/DEBUG:     r8 12c5d190  r9 b8cbad20 …
Run Code Online (Sandbox Code Playgroud)

android segmentation-fault retrofit retrofit2

7
推荐指数
1
解决办法
720
查看次数