Android UI, GridView, ScrollView, SlidingDrawer 抽屉滑动效果
2014-11-14 16:28
441 查看
1. GridView 关键点还是在于adapter的实现
GridViewActivity.java
2. ScrollView 是一个framelayout, 下面只能有一个控件, 一般为linearlayout
可以通过 android:scrollbarThumbVertical 来设置 滚动条的图形
3. SlidingDrawer 抽屉滑动效果
可以设置水平垂直方向, 可以根据需求自定义 content
GridViewActivity.java
public class GridViewActivity extends Activity { private int[] images; private GridView gridView; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.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{ @Override public int getCount() { // TODO Auto-generated method stub return images.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return images[position]; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public 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>
相关文章推荐
- 【小功能4】android用SlidingDrawer实现抽拉的滑动效果(也叫抽屉)附源码
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- Android SlidingDrawer 滑动抽屉效果
- Android之抽屉效果(自定义、GridView、SlidingDrawer结合)案例
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- android 抽屉效果,内容GridView来实现单行滑动
- Android之抽屉效果(自定义、GridView、SlidingDrawer结合)案例
- Android UI开发第九篇——SlidingDrawer 抽屉效果
- (转)Android中Button、ListView、GridView的按键UI效果
- Android UI开发第八篇——ViewFlipper 左右滑动效果
- Android 滑动效果基础篇(四)—— Gallery + GridView
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题
- Android 滑动效果基础篇(四)—— Gallery + GridView
- android GridView横向滑动后 为什么MyGridView.setSelection(position) 就没效果了
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题
- android界面 slidingdrawer抽屉 从左侧拉出效果
- Android Apps 滑动式抽屉(SlidingDrawer)效果
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题