要想实现自定义gridview效果,有下边几个步骤:

1、定义grivew中的item的xml文件

 

假如item需要显示一个图片,图片下边显示文字:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="100dp"
 4     android:layout_height="100dp"
 5     android:orientation="vertical"
 6      >
 7     
 8     <Button
 9         android:id="@+id/button_gridview_item"
10         android:layout_width="130dp"
11         android:layout_height="130dp"
12         android:text=""
13         
14         android:focusable="false"
15         android:clickable="false"
16         
17         android:textColor="#ffffff"
18         android:textSize="36sp"
19         />
20     
21      <TextView
22         android:id="@+id/tv_login_staff_name"
23         android:layout_width="130dp"
24         android:layout_height="30dp"
25         android:text="button"
26         
27         android:focusable="false"
28         android:clickable="false"
29         android:textSize="15sp"
30         android:gravity="center"
31         android:textColor="#ffffff"
32         />
33     
34 </LinearLayout>
View Code

相关文章:

  • 2021-10-18
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2021-12-01
  • 2022-02-16
相关资源
相似解决方案