編輯:關於Android編程
一.啟動動畫的漸變:
以後可能會用到的啟動動畫的效果:
效果圖:
主界面:
public class MainActivity extends Activity { private LandingView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); lv = new LandingView(this); // 將自定義視圖顯示在本界面 setContentView(lv); // 創建修改Logo透明度的異步任務 LoGoTask task = new LoGoTask(this,lv); // 執行異步任務 task.execute(); } }
public class LoGoTask extends AsyncTask
public class LandingView extends View{ private int alpha = 0; private Bitmap logo; private Context context; public LandingView(Context context) { super(context); this.context = context; logo = BitmapFactory.decodeResource(context.getResources(), R.drawable.background1); } public void redraw(int aplha){ this.alpha = aplha; invalidate(); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); // 清屏 canvas.drawColor(Color.WHITE); // 創建畫筆對象 Paint p = new Paint(); // 設置畫筆對象的透明度為當前透明度取值 p.setAlpha(alpha); WindowManager manager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm=new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); int width2=dm.widthPixels; int height2=dm.heightPixels; // 在視圖上利用畫筆繪制Logo圖像 RectF rect = new RectF(0,0,width2,height2); canvas.drawBitmap(logo, null, rect, p); } }
public class TestActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
一 概述本文是Android導航分組列表系列上,因時間和篇幅原因分上下,最終上下合璧,完整版效果如下:上部殘卷效果如下網上關於實現帶懸停分組頭部的列表的方法有很多,像我看
1.創建一個類繼承viewpublic class MyToggleButton extends View { private static final String N
開篇先介紹幾個放在眼前卻經常忽視的快捷鍵如圖:展現出android Studio超強的搜索能力,提高大工程的開發維護效率。雙擊Shift按鍵效果Ctrl+Shift+N
在Android中關於日期時間的類有TimePicker、DatePicker、TimePickerDialog、DatePickerDial