zoukankan      html  css  js  c++  java
  • 横向 gridView 一行 滚动

    引用:http://www.eoeandroid.com/thread-14382-2-1.html

    <HorizontalScrollView android:id="@+id/hsView"
            android:layout_width="fill_parent" android:layout_height="wrap_content" 
            android:visibility="gone"  android:background="#E9E9E9">
                <LinearLayout
                    android:layout_width="fill_parent"  android:layout_height="wrap_content" 
                    android:orientation="horizontal">
                    <GridView  android:id="@+id/gridView"
                        android:layout_width="fill_parent" android:layout_height="wrap_content" />
                </LinearLayout>
        </HorizontalScrollView>
    ----------------------------------------------------------------------
    MainActivity.java

      LayoutParams params = new LayoutParams(videoList.size() * (columnWidth+horizontalSpacing),LayoutParams.WRAP_CONTENT);
        gridView.setLayoutParams(params);    //gridView的整体宽度
        gridView.setColumnWidth(360);   //列宽(像素)
        gridView.setHorizontalSpacing(4);  //水平间距
        gridView.setStretchMode(GridView.NO_STRETCH);   //不拉伸
        gridView.setNumColumns(videoList.size());      //一排显示几列

  • 相关阅读:
    Beta 冲刺 (2/7)
    Beta 冲刺 (1/7)
    2017软件工程实践总结
    华为软件开发云评测
    android开发——用户头像
    学生&部门智能匹配程序
    学生会里学生汇
    数独棋盘生成器
    读与思
    Java接口
  • 原文地址:https://www.cnblogs.com/sode/p/2177735.html
Copyright © 2011-2022 走看看