android popupwindow 动画 特效 案例

先看图:


Ok,上面的效果为POPUPWINDOW简单的实现效果,下面我就把核心代码贴出来吧,希望能对想关朋友做个参考,可以通个这个小的按列来对自己做更好的扩展:

直接贴代码了:

package com.lenovo.roll;


import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.os.Bundle;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;


/**
 * 
 * @author jankey
 *
 */
public class RollActivity extends Activity {
private View view;
private Button btn;
private PopupWindow mPopupWindow;
private View[] btns;
private GridView mListViews;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btn=(Button) this.findViewById(R.id.btn);
        btn.setOnClickListener(new OnClickListener(){


@Override
public void onClick(View v) {
showPopupWindow(btn);
}
       
        });
        
        initPopupWindow(R.layout.popwindow);


    }
    
private void initPopupWindow(int resId){
LayoutInflater mLayoutInflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
   view = mLayoutInflater.inflate(resId, null);
       
mPopupWindow = new PopupWindow(view, 400,LayoutParams.WRAP_CONTENT);
mPopupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_frame));
mPopupWindow.setOutsideTouchable(true);

mPopupWindow.setAnimationStyle(R.style.PopupAnimation);
mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
mPopupWindow.update();
mPopupWindow.setTouchable(true);
mPopupWindow.setFocusable(true);

btns=new View[4];
btns[0]=view.findViewById(R.id.btn_0);
btns[1]=view.findViewById(R.id.btn_1);
btns[2]=view.findViewById(R.id.btn_2);
mListViews = (GridView) view.findViewById(R.id.listViews);

String str="这只是测试,但是这是可以运用在项目中的,你需要仔细参看";
SpannableStringBuilder stryle = new SpannableStringBuilder(str);
stryle.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stryle.setSpan(new ForegroundColorSpan(Color.RED), 4, 11, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
stryle.setSpan(new ForegroundColorSpan(Color.WHITE), 11, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ArrayList<Beans> arrs = new ArrayList<Beans>();
Beans b = new Beans();
for (int i = 0; i < 20; i++) {
b.setId(R.drawable.home_light);
b.setName(stryle+"this is title");
b.setStrs("this is content!");
arrs.add(b);
}
mListView

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值