2017-10-18 3 views
0

나는 소녀 패션 카테고리를 보여줄 앱을 개발 중입니다. 나는 격자보기에서 카테고리를 표시하려했다. 하지만 내가 애플 리케이션을 테스트 할 때 그리드 뷰는 스크롤하는 동안 끊어지고있다. 그리고 내 코드는 다음과 같습니다. 이걸 도와주세요. 미리 감사드립니다.스크롤하는 동안 GridView가 깨지십니까?

enter image description here

single_item.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:padding="10dp" 
android:orientation="vertical" 
android:gravity="center"> 

<ImageView 
    android:layout_width="150dp" 
    android:layout_height="150dp" 
    android:id="@+id/grid_image"/> 

<TextView 
    android:maxLines="1" 
    android:layout_marginTop="10dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/grid_text" 
    android:textColor="#000" 
    android:textSize="20sp" 
    android:gravity="center"/> 

</LinearLayout> 

activity_browse.xml 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
tools:context="com.example.user.beautyworld.BrowseActivity"> 


<GridView 
    android:id="@+id/grid_view" 
    android:layout_width="match_parent" 
    android:padding="10dp" 
    android:numColumns="auto_fit" 
    android:gravity="center" 
    android:columnWidth="150dp" 
    android:layout_height="match_parent"> 

</GridView> 

</LinearLayout> 

답변

0

대신 LinearLayout의 목적을 위해 RelativeLayout를 사용할 수 있습니다.

single_item.xml이 답변이 이미 here을 제공 한

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#2a2a2a" > 

<GridView 
    android:id="@+id/grid_view" 
    android:layout_width="match_parent" 
    android:padding="10dp" 
    android:numColumns="auto_fit" 
    android:gravity="center" 
    android:columnWidth="150dp" 
    android:layout_height="match_parent"> 

</GridView> 

</RelativeLayout> 

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#2a2a2a" > 

<ImageView 
    android:layout_width="150dp" 
    android:layout_height="150dp" 
    android:id="@+id/grid_image"/> 

<TextView 
    android:maxLines="1" 
    android:layout_marginTop="10dp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/grid_text" 
    android:textColor="#000" 
    android:textSize="20sp" 
    android:gravity="center"/> 

</RelativeLayout> 

activity_browse.xml.

+0

여전히 문제에 직면하고 있습니다. –