Reputation: 85
my xml code
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:numColumns="2"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:layout_margin="10dp"
/>
my current output;
I want to maintain equal width and height for every item in grid. Then when I have more items the Scroll is slow or get struck in app.
my items xml;
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#12000000"
app:cardCornerRadius="3dp"
app:cardPreventCornerOverlap="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:id="@+id/img_grid_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/asc_logo"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="@+id/txt_extension"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="16sp"
/>
<Button
android:id="@+id/btn_popup"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/ic_more_vert"
android:backgroundTint="#000000"
android:layout_gravity="end"
style="@style/Base.Widget.AppCompat.Button.Borderless"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
the design has done with matchparent and layout weight in order to have equal height
Upvotes: 0
Views: 197