Imitating the android QQ space today, the effect is as follows:
Open the startup screen and navigation page of the program and I will not do it. You can do it as easily as you can. This time, we mainly implement the Home Page. The layout of the home page is as follows:
Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: background = "@ android: color/white"
Android: orientation = "vertical">
<Include
Android: id = "@ + id/top_layout"
Layout = "@ layout/main"/>
</LinearLayout>
It references the layout file main. Its xml file is:Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
<RelativeLayout
Android: layout_width = "fill_parent"
Android: layout_height = "40dip"
Android: layout_alignParentTop = "true"
Android: background = "@ drawable/navbar_bg">
<TextView
Android: id = "@ + id/titltext"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "My Space Dynamics"
Android: textSize = "20dp"
Android: layout_centerInParent = "true"
/>
<ImageView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_centerInParent = "true"
Android: src = "@ drawable/navbar_drop_down"
Android: id = "@ + id/bytextimage1"
Android: layout_toRightOf = "@ id/titltext"
/>
<ImageView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_centerInParent = "true"
Android: src = "@ drawable/navbar_drop_up"
Android: id = "@ + id/bytextimage2"
Android: visibility = "invisible"
Android: layout_toRightOf = "@ id/titltext"
/>
<ImageView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignParentRight = "true"
Android: layout_marginTop = "5dp"
Android: layout_marginRight = "10dp"
Android: src = "@ drawable/icon_refresh_none"/>
</RelativeLayout> // This RelativeLayout is the layout of the "My Space Dynamics" section at the top.
<FrameLayout // The Implementation of the navigation bar below. The background is the part of the gray stripe.
Android: layout_width = "fill_parent"
Android: layout_height = "65.00009dip"
Android: layout_alignParentBottom = "true"
Android: background = "@ drawable/toolbar_bg">
<LinearLayout // used to contain images and text
Android: layout_width = "fill_parent"
Android: layout_height = "481_dip"
Android: layout_gravity = "bottom"
Android: baselineAligned = "false"
Android: gravity = "center_horizontal"
Android: orientation = "horizontal">
<FrameLayout // uses a frame layout, so that the image and text can be displayed together. Of course, you can also use the relative layout, one on and one on.
Android: layout_width = "fill_parent"
Android: layout_height = "481_dip"
Android: layout_weight = "1.0">
<ImageView
Android: layout_width = "281_dip"
Android: layout_height = "281_dip"
Android: layout_gravity = "top | center"
Android: layout_marginTop = "1.0dip"
Android: contentDescription = ""
Android: src = "@ drawable/tab_timefeed_opacity"
Android: visibility = "visible"/>
<TextView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "bottom | center"
Android: layout_marginBottom = "6.0dip"
Android: text = "friend Dynamics"
Android: textColor = "# ffffffff"
Android: textSize = "10.0dip"
Android: visibility = "visible"/>
</FrameLayout>
<FrameLayout
Android: layout_width = "fill_parent"
Android: layout_height = "481_dip"
Android: layout_marginRight = "10.0dip"
Android: layout_weight = "1.0">
<ImageView
Android: layout_width = "271_dip"
Android: layout_height = "27347dip"
Android: layout_gravity = "top | center"
Android: layout_marginTop = "1.0dip"
Android: src = "@ drawable/tab_feedback_opacity"
Android: visibility = "visible"/>
<TextView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "bottom | center"
Android: layout_marginBottom = "6.0dip"
Android: text = "related to me"
Android: textColor = "# ffffffff"
Android: textSize = "10.0dip"
Android: visibility = "visible"/>
<TextView
Android: layout_width = "172.16dip"
Android: layout_height = "172.16dip"
Android: layout_gravity = "center_horizontal"
Android: layout_marginBottom = "15.0dip"
Android: layout_marginLeft = "10.0dip"
Android: background = "@ drawable/myhome_visitor_number"
Android: gravity = "center_vertical"
Android: paddingBottom = "5.0dip"
Android: paddingLeft = "5.0dip"
Android: paddingRight = "0.0dip"
Android: paddingTop = "0.0dip"
Android: text = "n"
Android: textColor = "# ffffffff"
Android: textSize = "13.0dip"
Android: visibility = "visible"/>
</FrameLayout>
<FrameLayout
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: layout_weight = "1.0"/>
<FrameLayout
Android: layout_width = "fill_parent"
Android: layout_height = "481_dip"
Android: layout_marginLeft = "10.0dip"
Android: layout_weight = "1.0">
<ImageView
Android: layout_width = "271_dip"
Android: layout_height = "27347dip"
Android: layout_gravity = "top | center"
Android: layout_marginTop = "1.0dip"
Android: src = "@ drawable/tab_myzone_opacity"
Android: visibility = "visible"/>
<TextView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "bottom | center"
Android: layout_marginBottom = "6.0dip"
Android: text = "Homepage"
Android: textColor = "# ffffffff"
Android: textSize = "10.0dip"
Android: visibility = "visible"/>
</FrameLayout>
<FrameLayout
Android: layout_width = "fill_parent"
Android: layout_height = "481_dip"
Android: layout_weight = "1.0">
<ImageView
Android: layout_width = "271_dip"
Android: layout_height = "27347dip"
Android: layout_gravity = "top | center"
Android: layout_marginTop = "1.0dip"
Android: src = "@ drawable/tab_applist_opacity"
Android: visibility = "visible"/>
<TextView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "bottom | center"
Android: layout_marginBottom = "6.0dip"
Android: text = "app"
Android: textColor = "# ffffffff"
Android: textSize = "10.0dip"
Android: visibility = "visible"/>
</FrameLayout>
</LinearLayout>
<FrameLayout
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "center_horizontal">
<ImageView
Android: layout_width = "66.666595dip"
Android: layout_height = "65.33328dip"
Android: layout_gravity = "center"
Android: src = "@ drawable/toolbar_write_bg"/>
</FrameLayout>
<FrameLayout
Android: id = "@ + id/btn_ck"
Android: layout_width = "65.33328dip"
Android: layout_height = "65.33328dip"
Android: layout_gravity = "center">
<ImageView
Android: id = "@ + id/image1"
Android: layout_width = "22.666595dip"
Android: layout_height = "22.666595dip"
Android: layout_gravity = "center"
Android: layout_marginTop = "2.0dip"
Android: src = "@ drawable/toolbar_plus"/>
</FrameLayout>
</FrameLayout>
</RelativeLayout>
The above "My Space Dynamics" and the circle Button below use PopubWindow. the Activity code is as follows:Copy codeThe Code is as follows: package com. example. imitateqqzone;
Import java. util. ArrayList;
Import java. util. List;
Import android. OS. Bundle;
Import android. app. Activity;
Import android. content. Context;
Import android. graphics. drawable. BitmapDrawable;
Import android. view. LayoutInflater;
Import android. view. Menu;
Import android. view. View;
Import android. view. View. OnClickListener;
Import android. view. Window;
Import android. widget. AdapterView;
Import android. widget. ImageView;
Import android. widget. LinearLayout;
Import android. widget. ListView;
Import android. widget. PopupWindow;
Import android. widget. TextView;
Import android. widget. AdapterView. OnItemClickListener;
Import android. widget. Toast;
Public class ImitateQQZone extends Activity {
Private PopupWindow popupWindow1, popupWindow2;
Private ListView lv_group;
Private View view, top_layout;
Private TextView tvtitle;
Private List <String> groups;
// Private int screenWidth, screenHeight, dialgoWidth, dialgoheight;
Private ImageView byTextImageView1, byTextImageView2, centerimage;
// Private int [] images = {R. drawable. navbar_drop_down, R. drawable. navbar_drop_up };
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
This. requestWindowFeature (Window. FEATURE_NO_TITLE );
SetContentView (R. layout. activity_imitate_qqzone );
Top_layout = this. findViewById (R. id. top_layout );
Tvtitle = (TextView) top_layout.findViewById (R. id. titltext );
ByTextImageView1 = (ImageView) top_layout.findViewById (R. id. bytextimage1 );
ByTextImageView2 = (ImageView) top_layout.findViewById (R. id. bytextimage2 );
Centerimage = (ImageView) findViewById (R. id. image1 );
/*
* Android view setVisibility ():
There are three Parameters: visibility One of VISIBLE, INVISIBLE, or GONE. The expected three constant values are 0, 4, and 8.
VISIBLE: 0 indicates VISIBLE
INVISIBILITY: 4 indicates invisible, but still occupies the original space.
GONE: 8 indicates invisible and does not occupy the original layout space.
*/
Tvtitle. setOnClickListener (new OnClickListener (){
Boolean isImage = false;
Public void onClick (View v ){
ShowWindow1 (v );
If (isImage = false ){
IsImage = true;
ByTextImageView1.setVisibility (4 );
ByTextImageView2.setVisibility (0 );
} Else {
IsImage = false;
ByTextImageView1.setVisibility (0 );
ByTextImageView2.setVisibility (4 );
}
}
});
Centerimage. setOnClickListener (new OnClickListener (){
Public void onClick (View v ){
ShowWindow2 (v );
}
});
}
Protected void showWindow2 (View v ){
If (popupWindow2 = null ){
LayoutInflater layoutInflater = (LayoutInflater) getSystemService (Context. LAYOUT_INFLATER_SERVICE );
View = layoutInflater. inflate (R. layout. pubmenu, null );
PopupWindow2 = new PopupWindow (view, 400,400); // create a PopuWidow object
}
PopupWindow2.setFocusable (true); // aggregates
PopupWindow2.setOutsideTouchable (true); // The setting allows the exit click to disappear.
PopupWindow2.setBackgroundDrawable (new BitmapDrawable (); // click "Back" to make it disappear without affecting your background.
PopupWindow2.showAsDropDown (v );
}
Private void showWindow1 (View parent ){
If (popupWindow1 = null ){
LayoutInflater layoutInflater = (LayoutInflater) getSystemService (Context. LAYOUT_INFLATER_SERVICE );
View = layoutInflater. inflate (R. layout. group_list, null );
Lv_group = (ListView) view. findViewById (R. id. lvGroup );
// Load data
Groups = new ArrayList <String> ();
Groups. add ("all dynamic ");
Groups. add ("friend Dynamics ");
Groups. add ("special concern ");
Groups. add ("authentication space ");
GroupAdapter groupAdapter = new GroupAdapter (this, groups );
Lv_group.setAdapter (groupAdapter );
// Create a PopuWidow object
PopupWindow1 = new PopupWindow (Views, 200,350 );
}
PopupWindow1.setFocusable (true); // aggregates
PopupWindow1.setOutsideTouchable (true); // The setting allows the exit click to disappear.
PopupWindow1.setBackgroundDrawable (new BitmapDrawable (); // click "Back" to make it disappear without affecting your background.
// ScreenWidth = ImitateQQZone. this. getWindowManager (). getDefaultDisplay (). getWidth ();
// ScreenHeight = ImitateQQZone. this. getWindowManager (). getDefaultDisplay (). getHeight ();
// DialgoWidth = popupWindow. getWidth ();
// Dialgoheight = popupWindow. getHeight ();
// Int xPos = (screenWidth-dialgoWidth)/2; // display position: half of the screen width-half of the PopupWindow width
// Log. I ("coder", "xPos:" + xPos );
PopupWindow1.showAsDropDown (parent );
Lv_group.setOnItemClickListener (new OnItemClickListener (){
Public void onItemClick (AdapterView <?> AdapterView, View view,
Int position, long id ){
Toast. makeText (ImitateQQZone. this, groups. get (position), 1000)
. Show ();
// Switch (position ){
// Case 0:
// Intent intent = new Intent (ImitateQQZone. this,
// PopupWindowDemo2.class );
// StartActivity (intent );
/// Break;
// Default:
// Break;
//}
If (popupWindow1! = Null ){
PopupWindow1.dismiss ();
}
}
});
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
GetMenuInflater (). inflate (R. menu. activity_imitate_qqzone, menu );
Return true;
}
}
I will not post other layout files. If you need code, you can @ me or leave a message below. This is just a Demo. Due to the time relationship, there are still many details that are not implemented. You can continue to improve it on my own.