저는 안드로이드의 초보자입니다. 코드를 개선 할 수있는 곳에서 의견을 나누고 싶습니다.안드로이드 - GridView가 스크롤되지 않습니다.
우리 프로젝트에서 우리는 런타임에 사용자를로드하는 격자보기를 만들었지 만 이제는이 문제가 때때로 스크롤되지 않으므로 그렇게하기가 어렵습니다.
또한 우리는이 격자보기를 사용하여 응용 프로그램에서 요구하는 상황에 따라보기를 보이고 사라지게했습니다.
이<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- Title Layout -->
<RelativeLayout
android:id="@+id/newGroupTitleLayout"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="@drawable/topbar_bg" >
<ImageButton
android:id="@+id/newGroupCancelButton"
android:layout_width="60dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="@drawable/buttonanim_cancel_button"
android:contentDescription="@string/todo" />
<TextView
android:id="@+id/setupPrefTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/new_group"
android:textColor="@color/yellow"
android:textSize="20sp" />
</RelativeLayout>
<!-- Group Name -->
<LinearLayout
android:id="@+id/groupNameLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/newGroupTitleLayout"
android:layout_marginBottom="5dp"
android:layout_marginTop="15dp"
android:orientation="vertical" >
<TextView
android:id="@+id/groupNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/group_name"
android:textColor="@color/yellow" />
<EditText
android:id="@+id/groupNameEditText"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:background="@drawable/full_textfield"
android:ems="10"
android:inputType="text"
android:nextFocusRight="@+id/stateEditText"
android:paddingLeft="15dp"
android:singleLine="true" >
</EditText>
</LinearLayout>
<RelativeLayout
android:id="@+id/addMemberLayout"
android:layout_width="wrap_content"
android:layout_height="290dp"
android:layout_below="@+id/groupNameLinearLayout"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:background="@drawable/membersbox" >
<!-- View used when more than 1 member present -->
<GridView
android:id="@+id/mebersListGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fastScrollAlwaysVisible="true"
android:gravity="center"
android:numColumns="auto_fit"
android:padding="10dp"
android:verticalSpacing="10dp"
android:visibility="gone" />
<!-- View when there are no members -->
<RelativeLayout
android:id="@+id/zeroMembersLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" >
<ImageButton
android:id="@+id/addMemeberImageButton"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="@drawable/buttonanim_addmembersmall_button"
android:contentDescription="@string/todo" />
<LinearLayout
android:id="@+id/memberCountStatementTextViewtLayout"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/addMemeberImageButton"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/this_group_has_"
android:textColor="@android:color/white"
android:textSize="19sp" />
<TextView
android:id="@+id/groupMembersCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/_0"
android:textColor="@color/yellow"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/_members"
android:textColor="@android:color/white"
android:textSize="19sp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/memberCountStatementTextViewtLayout"
android:layout_centerHorizontal="true"
android:text="@string/tap_to_add_friends"
android:textColor="@android:color/white"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
<!-- Create group button -->
<ImageButton
android:id="@+id/creategroupbutton"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_below="@+id/addMemberLayout"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:background="@drawable/buttonanim_creategroup_button"
android:contentDescription="@string/todo" />
</RelativeLayout></ScrollView>
이 사람이 나를 도울 수 :
여기 내 XML 파일입니까?
당신의 도움이 감사합니다.
정확하게는 아니지만 그리드보기 자체가 필요합니다. 부모 스크롤 뷰는 화면에서 스크롤 동작을 사용하고 하위 뷰는 스크롤 이벤트를 가져올 수 없으므로 위에서 언급 한 포인트가 옳습니다. 글쎄, 제안 주셔서 감사합니다. – Kailas
ListView를 사용하여 GridView와 거의 비슷한 기능을 수행 할 수 있습니다. GridView의 각 행은 ListView의 단일 하위 노드를 만들 수 있습니다. – GareginSargsyan