亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > Android > 正文

Android仿QQ空間主頁面的實現

2020-04-11 12:36:54
字體:
來源:轉載
供稿:網友
今天模仿安卓QQ空間,效果如下:
  
打開程序的啟動畫面和導航頁面我就不做了,大家可以模仿微信的那個做一下,很簡單。這次主要做一下主頁面的實現,下面是主頁面的布局:
復制代碼 代碼如下:

<?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>

里面引用了main這個布局文件,它的xml文件為:
復制代碼 代碼如下:

<?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="我的空間動態"
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>//這個RelativeLayout是最上面“我的空間動態”那一部分的布局
<FrameLayout //下面的導航欄的實現,他的背景就是灰色橫條的那一部分
android:layout_width="fill_parent"
android:layout_height="65.32999dip"
android:layout_alignParentBottom="true"
android:background="@drawable/toolbar_bg" >
<LinearLayout //用來包含圖片以及文字
android:layout_width="fill_parent"
android:layout_height="48.0dip"
android:layout_gravity="bottom"
android:baselineAligned="false"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<FrameLayout //采用幀布局,這樣圖片和文字就可以一起顯示了。當然也可以用相對布局,一個在上,一個在下。
android:layout_width="fill_parent"
android:layout_height="48.0dip"
android:layout_weight="1.0" >
<ImageView
android:layout_width="28.0dip"
android:layout_height="28.0dip"
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="好友動態"
android:textColor="#ffffffff"
android:textSize="10.0dip"
android:visibility="visible" />
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="48.0dip"
android:layout_marginRight="10.0dip"
android:layout_weight="1.0" >
<ImageView
android:layout_width="27.0dip"
android:layout_height="27.0dip"
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="與我相關"
android:textColor="#ffffffff"
android:textSize="10.0dip"
android:visibility="visible" />
<TextView
android:layout_width="17.0dip"
android:layout_height="17.0dip"
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="48.0dip"
android:layout_marginLeft="10.0dip"
android:layout_weight="1.0" >
<ImageView
android:layout_width="27.0dip"
android:layout_height="27.0dip"
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="主頁"
android:textColor="#ffffffff"
android:textSize="10.0dip"
android:visibility="visible" />
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="48.0dip"
android:layout_weight="1.0" >
<ImageView
android:layout_width="27.0dip"
android:layout_height="27.0dip"
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="應用"
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>

上面的“我的空間動態”以及下面的圓形Button用的是PopubWindow,Activity的代碼如下:
復制代碼 代碼如下:

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():
有三個參數:Parameters:visibility One of VISIBLE, INVISIBLE, or GONE,想對應的三個常量值:0、4、8
VISIBLE:0 意思是可見的
INVISIBILITY:4 意思是不可見的,但還占著原來的空間
GONE:8 意思是不可見的,不占用原來的布局空間
*/
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);// 創建一個PopuWidow對象
}
popupWindow2.setFocusable(true); // 使其聚集
popupWindow2.setOutsideTouchable(true);// 設置允許在外點擊消失
popupWindow2.setBackgroundDrawable(new BitmapDrawable());// 這個是為了點擊“返回Back”也能使其消失,并且并不會影響你的背景
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);
// 加載數據
groups = new ArrayList<String>();
groups.add("全部動態");
groups.add("好友動態");
groups.add("特別關心");
groups.add("認證空間");
GroupAdapter groupAdapter = new GroupAdapter(this, groups);
lv_group.setAdapter(groupAdapter);
// 創建一個PopuWidow對象
popupWindow1 = new PopupWindow(view, 200, 350);
}

popupWindow1.setFocusable(true); // 使其聚集
popupWindow1.setOutsideTouchable(true);// 設置允許在外點擊消失
popupWindow1.setBackgroundDrawable(new BitmapDrawable());// 這個是為了點擊“返回Back”也能使其消失,并且并不會影響你的背景

//screenWidth = ImitateQQZone.this.getWindowManager().getDefaultDisplay().getWidth();
//screenHeight = ImitateQQZone.this.getWindowManager().getDefaultDisplay().getHeight();
//dialgoWidth = popupWindow.getWidth();
//dialgoheight = popupWindow.getHeight();
//int xPos =(screenWidth-dialgoWidth)/2;// 顯示的位置為:屏幕的寬度的一半-PopupWindow的寬度的一半
//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;
}
}

其他的布局文件我就不貼出了,需要代碼的可以@我或在下面留言,這只是個Demo,因為時間關系,還有很多細節沒有實現。大家可以在我的基礎上繼續完善。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲iv一区二区三区| 国产成人jvid在线播放| 国产亚洲激情视频在线| 在线精品视频视频中文字幕| 国产有码一区二区| 国产精品极品美女粉嫩高清在线| 国产99视频精品免视看7| 国产精品九九久久久久久久| 精品国产欧美一区二区五十路| 日韩大陆欧美高清视频区| 欧美一级高清免费| 日韩av电影院| 欧美激情视频在线免费观看 欧美视频免费一| 日韩精品亚洲元码| 成人信息集中地欧美| 91精品视频在线免费观看| 久久免费少妇高潮久久精品99| 亚洲欧洲xxxx| 久久夜色精品国产欧美乱| 亚洲国产精品久久久久| 91国产高清在线| 成人国产精品久久久久久亚洲| 国产综合久久久久| 欧美午夜电影在线| 国产日韩精品视频| 欧美在线视频一区| 精品中文字幕久久久久久| 日韩一区av在线| 精品福利一区二区| 亚洲天堂网站在线观看视频| 精品久久久久久中文字幕一区奶水| 92看片淫黄大片欧美看国产片| 国产成人久久久精品一区| 亚洲爱爱爱爱爱| 日韩福利视频在线观看| 亚洲精品在线不卡| 另类天堂视频在线观看| 欧美日韩国产一区二区三区| 国产精品成av人在线视午夜片| 国产999精品| 高跟丝袜一区二区三区| 国产在线观看精品一区二区三区| 亚洲欧美中文日韩v在线观看| 日韩中文字幕欧美| 亚洲国产精品va在线看黑人动漫| 九九视频这里只有精品| 亚洲一区av在线播放| 欧美在线欧美在线| 一区二区三区美女xx视频| 最近2019中文字幕第三页视频| 国产精品嫩草影院久久久| 亚洲综合日韩在线| 欧美极品欧美精品欧美视频| 欧美日韩裸体免费视频| 亚洲网站在线播放| 国产99久久久欧美黑人| 精品偷拍各种wc美女嘘嘘| 精品久久久视频| 日韩在线视频国产| 欧美多人乱p欧美4p久久| 国模吧一区二区| 日韩av日韩在线观看| 欧美激情免费在线| 久久精品成人欧美大片古装| 欧美亚洲国产精品| 亚洲a成v人在线观看| 国产欧美欧洲在线观看| 欧美性猛交xxxx黑人| 国产美女91呻吟求| 日韩av资源在线播放| 亚洲第一区第一页| 91爱爱小视频k| 国产精品美女视频网站| 亚洲肉体裸体xxxx137| 最新国产成人av网站网址麻豆| 欧美丝袜一区二区三区| 亚洲国产精品va在线观看黑人| 国产91精品视频在线观看| 欧美色另类天堂2015| 韩剧1988在线观看免费完整版| 美日韩丰满少妇在线观看| 精品欧美国产一区二区三区| 国模精品视频一区二区| 国产一区二区三区三区在线观看| 日韩av在线免费播放| 国产精品久久电影观看| 欧美人交a欧美精品| 在线性视频日韩欧美| 国产精品日韩在线观看| 日韩av日韩在线观看| 美女久久久久久久久久久| 国产欧美日韩丝袜精品一区| 国产不卡一区二区在线播放| 日韩精品免费综合视频在线播放| 欧美激情精品久久久久久大尺度| 国产亚洲a∨片在线观看| 国产精品久久久久久久天堂| 欧美影院久久久| 久久夜色精品国产欧美乱| 国产午夜精品全部视频在线播放| 精品国产31久久久久久| 国产日韩欧美电影在线观看| 亚洲免费一在线| 国产日韩欧美一二三区| 在线播放国产一区中文字幕剧情欧美| 91久久精品国产91久久| 欧美激情精品久久久久久| 在线看片第一页欧美| 亚洲精品wwwww| 精品亚洲一区二区三区| 91精品国产91久久久久| 中文字幕亚洲欧美日韩高清| 国产欧美精品久久久| 欧美视频中文字幕在线| 欧美激情视频一区二区| 91精品国产自产在线老师啪| 日本成人免费在线| 亚洲国产精品成人精品| 韩国19禁主播vip福利视频| 97精品国产97久久久久久免费| 亚洲国产精品久久久久秋霞蜜臀| 国产综合久久久久久| 亚洲精品99999| 亚洲欧美在线一区二区| 欧美福利视频在线观看| 日韩高清电影免费观看完整版| 久久精品免费播放| 69**夜色精品国产69乱| 久久在线免费观看视频| 97国产精品人人爽人人做| 日韩三级影视基地| 成人午夜激情免费视频| 国产亚洲精品美女| 久久国产一区二区三区| 成人深夜直播免费观看| 91久热免费在线视频| 成人福利网站在线观看11| 欧美中文字幕第一页| 97国产一区二区精品久久呦| www.国产一区| 日日摸夜夜添一区| 国产日韩欧美自拍| 亚洲福利视频网站| 久久免费精品日本久久中文字幕| 国产suv精品一区二区三区88区| 国产亚洲精品久久久久久777| 亚洲欧美一区二区激情| 91免费福利视频| 97国产真实伦对白精彩视频8| 亚洲欧美精品在线| 日韩国产在线看| 美日韩精品视频免费看| 亚洲精品少妇网址| 欧美一区二粉嫩精品国产一线天| 97久久伊人激情网| 亚洲天堂成人在线| 精品激情国产视频| 久久精品2019中文字幕| 久久99精品久久久久久噜噜| 91精品国产91久久| 91人人爽人人爽人人精88v| 欧美极品美女电影一区| 亚洲理论电影网| 亚洲成人激情在线|