Я просто новичок в андроиде и хочу, чтобы ваши предложения были там, где я мог улучшить свой код.Android - GridView не прокрутка
Для нашего проекта мы создали сетку, которая загружает пользователей во время выполнения, теперь проблема заключается в том, что она не прокручивается время от времени, и это очень сложно сделать.
Также мы использовали этот вид сетки, делая вид видимым и ушедшим в зависимости от обстоятельств, требуемых приложением.
Вот мой XML-файл:
<?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>
Может кто-нибудь помочь мне с этим?
Ваша помощь приветствуется.
Не совсем, я хочу иметь вид сетки. Точка, о которой вы упомянули, верна, так как родительский прокрутка будет потреблять действие прокрутки на экране, а дочернее представление может не получить события прокрутки. Хорошо, спасибо за предложение. – Kailas
Вы можете использовать ListView и сделать его функцией почти как GridView. Каждая строка GridView может сделать бит одного дочернего элемента ListView. – GareginSargsyan