在某些设备中,Nevigation Drawer和Recycler View无法顺畅滚动

时间:2017-03-18 13:32:21

标签: android xml android-layout

我在布局中使用ImageView但是我从xml布局文件设置图像。我从服务器获取json数据,只是在recycler视图中显示该数据。但是它仍然在一些设备中滞后。这是我的活动布局文件: activity_home.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.pankajpathak.recycler_view_ex.fragments.Jobs_list_fragment">

    <LinearLayout
        android:id="@+id/linear_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorPrimary"
        android:gravity="center_vertical|end"
        android:orientation="horizontal"
        android:paddingLeft="16dp"
        android:paddingRight="16dp">

        <EditText
            android:id="@+id/et_search_job"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="30dp"
            android:layout_marginStart="30dp"
            android:background="@color/colorPrimary"
            android:hint="Search Job"
            android:inputType="text"
            android:maxLines="1"
            android:textColor="#fff"
            android:textColorHint="#e3e3e3" />

        <ImageButton
            android:id="@+id/btn_search_job"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/button_layout_transparent"
            android:src="@drawable/search_icon" />
    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rec_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

<fragment
    android:id="@+id/nevigation_drawer_fragment"
    android:name="freshers_job_pane.jobs.admin.race.fragments.Nevigation_drawer_fragment"
    android:layout_width="280dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    tools:layout="@layout/fragment_nevigation_drawer_fragment" />

这是片段布局文件 fragment_nevigation_drawer_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="280dp"
android:layout_height="match_parent"
android:background="#fff"
android:clickable="true">

<RelativeLayout
    android:id="@+id/relative_main"
    android:layout_width="match_parent"
    android:layout_height="110dp"
    android:background="@drawable/layout_lower_border">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/img_profile"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:src="@drawable/profile_new" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_below="@id/img_profile"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv_nevigation_drawer_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            android:text="Name"
            android:textColor="#fff"
            android:textSize="12sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tv_nevigation_drawer_sub_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            android:text="Email"
            android:textColor="#fff"
            android:textSize="12sp" />
    </LinearLayout>
</RelativeLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/rec_view_nevigation_options1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/relative_main" />

1 个答案:

答案 0 :(得分:0)

我通过减少我在RecyclerView中使用的图像大小来解决问题