Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement an Extensible header Control imitating QQ by Android

Shulou Source: shulou.com Published: 2022-06-03 09:35:31 11月15日 Update

Editor to share with you how to achieve Android imitating QQ stretchable head control, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The general idea of the control is:

1. Add the header view by inheriting listview. two。 Monitor listview scrolling. 3. Custom animation springback.

The layout of activity-main.xml is as follows:

Headerview.xml layout:

List_item layout:

"

Activity Code:

Package com.example.headerlistview;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import android.os.Bundle;import android.app.Activity;import android.view.LayoutInflater;import android.view.Menu;import android.view.View;import android.widget.BaseAdapter;import android.widget.ImageView;import android.widget.ListView;import android.widget.SimpleAdapter;public class MainActivity extends Activity {private HeaderListView header_lv; private ImageView header_iv @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); getHeaderView (); initView ();} private void initView () {/ / TODO Auto-generated method stub header_lv= (HeaderListView) findViewById (R.id.header_lv); header_lv.addHeaderView (getHeaderView ()); header_lv.setHeaderView (header_iv); header_lv.setAdapter (getSimpleAdapter ());} public BaseAdapter getSimpleAdapter () {List data=new ArrayList (); for (int item0

Tags: Controls height head layout time article pull content animation method original excessive not much continuous code most ideas execution period time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker vpn Redmi Linux