High imitation NetEase cloud Music client's home page switch tabhost-it Blue Panther

Source: Internet
Author: User

1. High imitation NetEase cloud Music client's home page switch Tabhost

High Imitation NetEase cloud Music client's home page switch Tabhost , and the triangles are transparent,
Implementation way, custom Animtabsview inheritance relativelayout in the face of the currently selected item processing triangle becomes transparent effect,
That is, in OnDraw, the triangle image is treated with transparency, Animtabsview provides setonanimtabsitemviewchangelistener
The onchange () method is used to monitor the click Toggle Tabhost.

The following are mainly implemented by the OnDraw () in Animtabsview, some Code as follows:

protected void OnDraw (canvas canvas) {
Super.ondraw (canvas);
if ((This.mscroller = = null) | | (!this.mscroller.computescrolloffset ())) {
This.mLeftDrawRect.set (0, This.mcurrentslidey, This.mcurrentslidex, This.mcurrentslidey + this.mShadow.getHeight ()) ;
Canvas.drawbitmap (This.mshadow, NULL, this.mleftdrawrect, NULL);
This.mRightDrawRect.set (This.mcurrentslidex + this.mSlideIcon.getWidth (), This.mcurrentslidey, GetWidth (), This.mcurrentslidey
+ this.mShadow.getHeight ());
Canvas.drawbitmap (This.mshadow, NULL, this.mrightdrawrect, NULL);
Canvas.drawbitmap (This.mslideicon, This.mcurrentslidex, This.mcurrentslidey, NULL);
Return
}
int scrollx = This.mScroller.getCurrX ();
int scrolly = This.mScroller.getCurrY ();
This.mLeftDrawRect.set (0, scrolly, SCROLLX, scrolly + this.mShadow.getHeight ());
Canvas.drawbitmap (This.mshadow, NULL, this.mleftdrawrect, NULL);
This.mRightDrawRect.set (Scrollx + this.mSlideIcon.getWidth (), scrolly, GetWidth (),
Scrolly + this.mShadow.getHeight ());
Canvas.drawbitmap (This.mshadow, NULL, this.mrightdrawrect, NULL);
Canvas.drawbitmap (This.mslideicon, SCROLLX, scrolly, NULL);
Invalidate ();
}

Operating Effect:

650) this.width=650; "src=" http://www.itlanbao.com/code/users/10000/20151009/itlanbao_10_9_tab.jpg "style=" border : 0px; "/>

 2.FlipViewPager to the item to achieve left and right fold sliding page effect

Flipviewpager to each item to achieve the left and right fold sliding page effect to solve the event distribution processing mechanism of left and right swipe and swipe up and down.
The internal implementation is as follows: With the ListView test, set adapter to the ListView, this adapter inherit baseflipadapter<friend>
, and then the view processing for each item, some of the code is as follows:
Class Friendsadapter extends Baseflipadapter<friend> {

Private final int PAGES = 3;
Private int[] Ids_interest = {r.id.interest_1, r.id.interest_2, R.id.interest_3, R.id.interest_4, R.id.interest_5};

Public Friendsadapter (context context, list<friend> items, flipsettings settings) {
Super (context, items, settings);
}

@Override
Public View getpage (int position, view Convertview, ViewGroup parent, friend Friend1, friend Friend2) {
Final Friendsholder Holder;

if (Convertview = = null) {
Holder = new Friendsholder ();
Convertview = Getlayoutinflater (). Inflate (R.layout.friends_merge_page, parent, false);
Holder.leftavatar = (ImageView) Convertview.findviewbyid (R.id.first);
Holder.rightavatar = (ImageView) Convertview.findviewbyid (R.id.second);
Holder.infopage = Getlayoutinflater (). Inflate (R.layout.friends_info, parent, false);
Holder.nickname = (TextView) holder.infoPage.findViewById (r.id.nickname);

for (int id:ids_interest)
Holder.interests.add ((TextView) holder.infoPage.findViewById (id));

Convertview.settag (holder);
} else {
Holder = (friendsholder) convertview.gettag ();
}

Switch (position) {
Merged page with 2 friends
Case 1:
Holder.leftAvatar.setImageResource (Friend1.getavatar ());
if (friend2! = null)
Holder.rightAvatar.setImageResource (Friend2.getavatar ());
Break
Default
Fillholder (Holder, Position = = 0? friend1:friend2);
Holder.infoPage.setTag (holder);
return holder.infopage;
}
return convertview;
}

@Override
public int Getpagescount () {
return PAGES;
}

private void Fillholder (Friendsholder holder, friend friend) {
if (friend = = null)
Return
iterator<textview> iviews = Holder.interests.iterator ();
iterator<string> iinterests = friend.getinterests (). Iterator ();
while (Iviews.hasnext () && iinterests.hasnext ())
Iviews.next (). SetText (Iinterests.next ());
Holder.infoPage.setBackgroundColor (Getresources (). GetColor (Friend.getbackground ()));
Holder.nickName.setText (Friend.getnickname ());
}

Class Friendsholder {
ImageView Leftavatar;
ImageView Rightavatar;
View Infopage;

list<textview> interests = new arraylist<> ();
TextView nickname;
}
}

Operating Effect:

650) this.width=650; "Src=" Http://www.itlanbao.com/code/users/10000/20151009/itlanbao_2015_10_9_pagerq2.gif " Style= "border:0px;"/>


This article is from the "target near" blog, so be sure to keep this source http://20165520.blog.51cto.com/10719434/1701451

High imitation NetEase cloud Music client's home page switch tabhost-it Blue Panther

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.