Android UI, GridView, ScrollView, SlidingDrawer 抽屉滑动效果
来源:互联网 发布:男人眼中的女人味知乎 编辑:程序博客网 时间:2024/04/30 16:57
1. GridView 关键点还是在于adapter的实现
GridViewActivity.java
public class GridViewActivity extends Activity {private int[] images;private GridView gridView;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.layout_gridview);gridView = (GridView) findViewById(R.id.gridView1);images = new int[]{R.drawable.sample_0,R.drawable.sample_1,R.drawable.sample_2,R.drawable.sample_3,R.drawable.sample_4,R.drawable.sample_5,R.drawable.sample_6,R.drawable.sample_7};MyImageAdapter adapter = new MyImageAdapter();gridView.setAdapter(adapter);}class MyImageAdapter extends BaseAdapter{@Overridepublic int getCount() {// TODO Auto-generated method stubreturn images.length;}@Overridepublic Object getItem(int position) {// TODO Auto-generated method stubreturn images[position];}@Overridepublic long getItemId(int position) {// TODO Auto-generated method stubreturn position;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {ImageView iv = new ImageView(GridViewActivity.this);iv.setImageResource(images[position]);return iv;}} }layout_gridview.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <GridView android:id="@+id/gridView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:numColumns="3" android:horizontalSpacing="6dp" android:verticalSpacing="6dp" > </GridView></LinearLayout>
2. ScrollView 是一个framelayout, 下面只能有一个控件, 一般为linearlayout
可以通过 android:scrollbarThumbVertical 来设置 滚动条的图形
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbarThumbVertical="@drawable/ic_launcher" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> </ScrollView>
3. SlidingDrawer 抽屉滑动效果
可以设置水平垂直方向, 可以根据需求自定义 content
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <SlidingDrawer android:id="@+id/slidingDrawer1" android:layout_width="match_parent" android:layout_height="match_parent" android:content="@+id/content" android:handle="@+id/handle" android:orientation="horizontal" > <Button android:id="@+id/handle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Handle" android:background="@drawable/button1" /> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/sample_0" /> </LinearLayout> </SlidingDrawer></LinearLayout>
0 0
- Android UI, GridView, ScrollView, SlidingDrawer 抽屉滑动效果
- Android SlidingDrawer 滑动抽屉效果
- Android Apps 滑动式抽屉(SlidingDrawer)效果
- Android之抽屉效果(自定义、GridView、SlidingDrawer结合)案例
- Android之SlidingDrawer滑动抽屉
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- Android之SlidingDrawer抽屉效果
- Android之SlidingDrawer抽屉效果
- android 抽屉效果 (SlidingDrawer)
- android SlidingDrawer滑动式抽屉控件
- Android开发之SlidingDrawer(滑动式抽屉)
- Android SlidingDrawer(滑动式抽屉)
- Android 用SlidingDrawer实现抽屉效果
- android之SlidingDrawer实现抽屉效果
- android之SlidingDrawer实现抽屉效果
- android基于SlidingDrawer实现抽屉效果
- php从数据库中取二进制流文件转换为图片,图片以二进制流存入数据库实现
- ecshop商品列表页面增加按销量排行
- 获得当前视图
- 为什么要使用ToolBar代替ActionBar
- JUnit in Action 2nd Edition 第三章 精通Junit(2)
- Android UI, GridView, ScrollView, SlidingDrawer 抽屉滑动效果
- 关于全局脚本和对象脚本
- cc150:实现一个算法从一个单链表中返回倒数第n个元素
- 內嵌html字符串顯示
- Android动态加载jar/dex
- Java中静态变量与静态方法的继承
- Android学习笔记(三)
- ASIHttpRequest请求HTTPS
- POJ 2229 Sumsets (递推&整数划分变形)