随笔分类 -  android界面绘制

1
摘要:仿Iphone时间选择滑动控件:WheelView.java:/** * @author Administrator * * 时间滑动滚轮 */public class WheelView extends View{ /** 手势监听控件 **/ private GestureDetector gestureDetector; /** 滑动管理类 **/ private Scroller scroller; /** 适配器 **/ private WheelAdapter adapter; private StaticLayout i... 阅读全文
posted @ 2013-11-04 13:54 暗殇 阅读(1295) 评论(0) 推荐(0)
摘要:仿网易新闻:实现原理:上面的导航栏是一个自定义的ViewGroup(类似ActionBar)中间内容层是ViewPager套fragment实现左右切换滑动fragment里面的布局是一个ListView 附带下拉刷新和下拉加载效果HeadView是一个ViewPager双层ViewPager如果处理子ViewPager的滑动冲突问题和点击事件通过自定义子ViewPager的方法:public class TeacherViewPager extends ViewPager implements OnGestureListener { private GestureDetector mD... 阅读全文
posted @ 2013-10-14 13:21 暗殇 阅读(4178) 评论(49) 推荐(1)
摘要:public class FragAdapter extends FragmentPagerAdapter { private List fragments ; public FragAdapter(FragmentManager fm){ super(fm); } public FragAdapter(FragmentManager fm,List fragments) { super(fm); this.fragments = fragments; } @Override public Fr... 阅读全文
posted @ 2013-09-23 10:02 暗殇 阅读(925) 评论(0) 推荐(1)
摘要:用ViewFlipper实现左右滑屏操作:1.注册ViewFilpper2.滑动动画:slideLeftOut.xml: slideRightOut.xml: 3.viewFilpper添加子view:viewFlipper.addView(mListView);viewFlipper.addView(mListView1);viewFlipper.addView(mListView2);子view监听onTouchEvent事件拦截子View的onTouchEvent事件 @Override public boolean onTouch(View v, MotionE... 阅读全文
posted @ 2013-05-03 14:12 暗殇 阅读(397) 评论(0) 推荐(0)
摘要:public class PullToRefreshView extends LinearLayout { private static final String TAG = "PullToRefreshView"; // refresh states private static final int PULL_TO_REFRESH = 2; private static final int RELEASE_TO_REFRESH = 3; private static final int REFRESHING = 4; // pull state pr... 阅读全文
posted @ 2013-03-09 17:11 暗殇 阅读(554) 评论(0) 推荐(0)
摘要:Android系统API Demos提供了伪3D旋转的例子,实现原理都是通过Camera API来进行处理.先附上源码:动画类Rotate3dAnimation:/** * An animation that rotates the view on the Y axis between two specified angles. * This animation also adds a translation on the Z axis (depth) to improve the effect. */public class Rotate3dAnimation extends Animati 阅读全文
posted @ 2013-02-04 13:38 暗殇 阅读(567) 评论(0) 推荐(0)
摘要:1.Canvas上以一定收缩比例贴一张图 headBgBmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.class_bg_sha1); headBmp = Bitmap.createBitmap(view.getWidth(),headBgBmp.getHeight(),Config.ARGB_8888); Canvas canvas2 = new Canvas(headBmp); Matrix matrix = new Matrix(); float xScale = (f... 阅读全文
posted @ 2013-01-23 14:00 暗殇 阅读(915) 评论(0) 推荐(0)
摘要:/** 创建MENU */ public boolean onCreateOptionsMenu(Menu menu) { menu.add("menu");// 必须创建一项 return super.onCreateOptionsMenu(menu); } /** 拦截MENU */ public boolean onMenuOpened(int featureId, Menu menu) { initPopuWindow(); return false;// 返回为tru... 阅读全文
posted @ 2012-12-08 10:47 暗殇 阅读(274) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * 圆 * @version 2012-12-5 */public class RingView extends View { private Paint paint; private Context context; private int radius;//半径 private int color;//颜色值 public RingView(Context context) { // TODO Auto-generated constructor stub ... 阅读全文
posted @ 2012-12-05 16:42 暗殇 阅读(1489) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * 翻书效果 * 2012-9-25 */public class TurnPage extends View{ private static final String TAG = TurnPage.class.getSimpleName(); private int mWidth = 620; private int mHeight = 770; private int mCornerX = 0; // 拖拽点对应的页脚 private int mCornerY = 0; private Path m... 阅读全文
posted @ 2012-10-18 11:52 暗殇 阅读(600) 评论(0) 推荐(1)
摘要:WindowManager.LayoutParams lp = new WindowManager.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutP... 阅读全文
posted @ 2012-10-09 11:13 暗殇 阅读(284) 评论(0) 推荐(0)
摘要:package com.cn.teachmobile.view;import android.content.Context;import android.os.Handler;import android.util.AttributeSet;import android.view.MotionEvent;import android.view.View;import android.view.animation.AccelerateInterpolator;import android.view.animation.Animation;import android.view.animatio 阅读全文
posted @ 2012-10-08 17:59 暗殇 阅读(432) 评论(0) 推荐(0)
摘要:public class autoScrollView extends ScrollView { private View inner; private float y; private Rect normal = new Rect(); public autoScrollView(Context context) { super(context); // TODO Auto-generated constructor stub } public autoScrollView(Context conte... 阅读全文
posted @ 2012-06-08 15:08 暗殇 阅读(925) 评论(0) 推荐(0)
摘要:public class PageDragView extends ViewGroup{ private static final String TAG = PageDragView.class.getSimpleName(); /** * 用来追踪触摸事件(flinging事件和其他手势事件)的速率 * 用obtain()函数来获得类的实例, * 用addMovement(MotionEvent)函数将motion event加入到VelocityTracker类实例中, * 当你使用到速率时,使用computeCurrentVelocity... 阅读全文
posted @ 2012-06-04 17:02 暗殇 阅读(571) 评论(0) 推荐(0)
摘要:很多情况下,我们需要自定义一些Dialog效果。首先继承系统的Dialog/** * @author gongchaobin * * 自定义Dialog样式 */public class SelfDialog extends Dialog implements android.view.View.OnClickListener{ private Context mContext; private Button mBtnCha; private Button mBtnUse; private ActivityManagerCommon managerCommon; ... 阅读全文
posted @ 2012-06-04 15:06 暗殇 阅读(308) 评论(0) 推荐(0)
摘要:抽屉样式作为一种比较常用的View,有很多实现方式。这里是一种简单的实现方式:第一步:布局文件 <!-- android:content 要展开的layout content android:handle 委托要展开的图片 --> <SlidingDrawer android:id="@+id/sliding" android:layout_width="match_parent" android:layout_height="match_parent" android:content="@+id/allA 阅读全文
posted @ 2012-05-29 09:28 暗殇 阅读(902) 评论(0) 推荐(0)
摘要:/** * @author gongchaobin * * 自定义popuwindow * @version 2012-12-12 */public class MyPopuWindow { private LayoutInflater mInflater; private PopupWindow mPopupWindow; private View mView; private Button mBtn; /** * @param context 上下文 * @param resId layout资源ID * @param width popuwindow的宽 * @param he... 阅读全文
posted @ 2012-05-23 15:12 暗殇 阅读(546) 评论(0) 推荐(0)
摘要:DialogCommon.java:package com.easier.gallery.common;import com.easier.gallery.R;import android.R.integer;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface;import android.graphics.Typeface;import android.os.Bundle;import android.view.LayoutInflater;i 阅读全文
posted @ 2012-05-10 16:20 暗殇 阅读(439) 评论(0) 推荐(0)
摘要:系统自带的Menu有各种限制条件,如何设置Menu的背景和文字的各项属性呢?在不自定义的情况下,也是可以设置Menu的背景的。/** 设置Menu的背景图 */ protected void setMenuBackground() { this.getLayoutInflater().setFactory( new android.view.LayoutInflater.Factory() { public View onCreateView(String name, Context context,Att... 阅读全文
posted @ 2012-05-10 16:17 暗殇 阅读(2757) 评论(0) 推荐(0)
摘要:Android客户端中,我们经常要实现图片滚轮的效果。实现的方式就是自定义相关View,这里主要是包括两个类:ImageScroller和PagerIndicator。PagerIndicator类:public class PagerIndicator extends ViewGroup { public static int mMaxTotalItems = 9; private int mTotalItems; private int mCurrentItem; private int mDotDrawableId;//滑动的图片 publi... 阅读全文
posted @ 2012-05-10 16:02 暗殇 阅读(726) 评论(0) 推荐(1)

1