Coder Social home page Coder Social logo

floatinglayeranimtion's Introduction

FloatingLayerAnimtion

滑动的浮层,支持添加各种View

Skip to content This repository
Search Pull requests Issues Gist @LinhaiGu Unwatch 1 Unstar 2 Fork 0 LinhaiGu/FloatingLayerAnimtion Code Issues 0 Pull requests 0 Wiki Pulse Graphs Settings Branch: master Find file Copy pathFloatingLayerAnimtion/FloatingLayerAnimtion/src/com/example/floatinglayeranimtion/MainActivity.java d726be2 on 20 Aug chen long new project 0 contributors RawBlameHistory 141 lines (105 sloc) 3.72 KB package com.example.floatinglayeranimtion;

public class MainActivity extends Activity implements OnClickListener {

private Button btn_show;
private Button btn_hide;
private GridView gv_all;

private TestAdapter testAdapter = new TestAdapter();


// 覆盖层
private FloatingLayerView mFloatingLayerView;

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	initView();
	addListener();
}

private void initView() {
	btn_show = (Button) findViewById(R.id.btn_show);
	btn_hide = (Button) findViewById(R.id.btn_hide);
	// 覆盖层
	mFloatingLayerView = (FloatingLayerView) findViewById(R.id.activity_shine_ll_cover);
	gv_all = (GridView) findViewById(R.id.activity_shine_gv_all);

	gv_all.setAdapter(testAdapter);

}

private void addListener() {
	btn_show.setOnClickListener(this);
	btn_hide.setOnClickListener(this);
	gv_all.setOnScrollListener(scrollListener);

}


@Override
public void onClick(View v) {
	switch (v.getId()) {

	// 显示浮层
	case R.id.btn_show:
		mFloatingLayerView.none2Half();
		break;

	// 隐藏浮层
	case R.id.btn_hide:
		mFloatingLayerView.beforeInput();
		break;

	}
}



/** 覆盖层中GridView滑动监听 */
private OnScrollListener scrollListener = new OnScrollListener() {

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
		if (firstVisibleItem == 0) {
			mFloatingLayerView.setCanHide(true);
		} else {
			mFloatingLayerView.setCanHide(false);
		}

	}

};


// =============测试======================
private int[] images = new int[] { R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
		R.drawable.ic_launcher };

class TestAdapter extends BaseAdapter {

	@Override
	public int getCount() {
		return images.length;
	}

	@Override
	public Object getItem(int position) {
		return images[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		View view = LayoutInflater.from(MainActivity.this).inflate(
				R.layout.image, null);
		
		ImageView imagView = (ImageView) view.findViewById(R.id.iv_show);
		imagView.setBackgroundResource(images[position]);
		return view;
	}

}

} Status API Training Shop Blog About Pricing © 2015 GitHub, Inc. Terms Privacy Security Contact Help

floatinglayeranimtion's People

Contributors

linhaigu avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.