当前位置:操作系统 > 安卓/Android >>

Android 抽屉式Activity(人人网所用(有图有易做图))

\\
 

---------------------------main.xml

<?xml version="1.0" encoding="utf-8"?> 
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
 
    <FrameLayout 
        android:id="@+id/slideout_placeholder" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:background="#777777" > 
 
        <ListView 
            android:id="@+id/list" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:cacheColorHint="#00000000" /> 
    </FrameLayout> 
 
    <ImageView 
        android:id="@+id/slidedout_cover" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:scaleType="fitXY" /> 
 
</AbsoluteLayout> 


------------------------blog.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/inner_content"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="45dip"
        android:background="#bb000000"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/sample_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dip"
            android:background="@drawable/right" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="I hate working 公子白"
            android:textColor="#ffffff"
            android:textSize="19sp" />
    </LinearLayout>

    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="40dip" />

</RelativeLayout>

 

 

------------------------------.主JAVA

package slidre.co.cc;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout.LayoutParams;

public class SettingActivity extends
  Activity {

 private ImageView mCover;
 private ListView mList;
 private Animation mStartAnimation;
 private Animation mStopAnimation;
 private static final int DURATION_MS = 400;
 private static Bitmap sCoverBitmap = null;
 String loveyouString[] = new String[] {
   "公子白工作室", "帅哥 帅哥 帅哥 帅哥",
   "帅哥", "美女", "帅哥 帅哥 帅哥",
   "帅哥 帅哥 帅哥 帅哥", "帅哥 帅哥 帅哥",
   "地上的娃娃笑哈哈" };

 // 2个步骤
 // 1. activity-->other activity
 // 2. anim
 // 先切换到另一个activity
 // 再获得之前activity屏幕的快照将它作为一个cover覆盖在下一个屏幕的上面,然后通过动画移动这个cover,让人感觉好像是前一个屏幕的移动。

 public static void prepare(
   Activity activity, int id) {
  if (sCoverBitmap != null) {
   sCoverBitmap.recycle();
  }
  // 用指定大小生成一张透明的32位位图,并用它构建一张canvas画布
  sCoverBitmap = Bitmap
    .createBitmap(
      activity.findViewById(
        id)
        .getWidth(),
      activity.findViewById(
        id)
        .getHeight(),
      Config.ARGB_8888);
  Canvas canvas = new Canvas(
   

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,