最近在做购物项目 左边分类是OpenTabHost,右侧是Fragment,切换分类显示不同的Fragment,每个Fragment里面放着一个Gridview来显示数据并要求行数到达最后一个自动跳转到第二个分类

找了很久 最后同事告诉了我两条属性,完美解决

 1 <!--android:nextFocusDown="@+id/title_bar2"-->
 2 <!--android:nextFocusLeft="@+id/title_bar2"-->
 3 <!--就是这两条属性,就可以指定跳转那任意控件的焦点-->
 4 <com.example.view.VideoGridView
 5     android:id="@+id/video_gridView"
 6     android:layout_width="match_parent"
 7     android:layout_height="560dp"
 8     android:layout_marginTop="2dp"
 9     android:layout_below="@+id/video1"
10     android:layout_centerHorizontal="true"
11     android:layout_marginLeft="20dp"
12     android:clipChildren="false"
13     android:columnWidth="200dp"
14     android:focusable="true"
15     android:focusableInTouchMode="true"
16     android:gravity="center_vertical"
17     android:horizontalSpacing="1dp"
18     android:listSelector="@drawable/selector_imagebottom"
19     android:nextFocusDown="@+id/title_bar2"
20     android:nextFocusLeft="@+id/title_bar2"
21     android:numColumns="3"
22     android:scrollbars="vertical"
23     android:verticalSpacing="12dp" />

是不是很神奇呢,附上一张效果图

Android学习笔记--Gridview的两个神奇属性



是不是好神奇

相关文章:

  • 2021-11-30
  • 2021-12-31
  • 2021-06-30
  • 2021-10-01
  • 2021-07-13
  • 2021-09-03
  • 2022-12-23
  • 2021-09-01
猜你喜欢
  • 2021-05-29
  • 2021-07-09
  • 2021-08-23
  • 2021-07-21
相关资源
相似解决方案