朋友圈简单实现
效果图
具体如下图所示:
朋友圈界面布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#e3e3e3"
android:orientation="vertical"
>
<Button
android:id="@+id/one"
android:layout_width="fill_parent"
android:layout_height="55sp"
android:text="@string/pengyouquan"
android:background="#ffffff"
android:drawableLeft="@drawable/pengyouquan"
android:gravity="left|center"
android:textSize="20sp"
android:layout_marginTop="5dp"/>
<Button
android:id="@+id/two"
android:layout_width="fill_parent"
android:layout_height="55sp"
android:text="@string/saoyisao"
android:background="#ffffff"
android:drawableLeft="@drawable/saoyisao"
android:gravity="left|center"
android:textSize="20sp"
android:layout_marginTop="12dp"/>
<Button
android:id="@+id/three"
android:layout_width="fill_parent"
android:layout_height="55sp"
android:text="@string/yaoyiyao"
android:background="#ffffff"
android:drawableLeft="@drawable/yaoyiyao_1"
android:gravity="left|center"
android:textSize="20sp"
android:layout_marginTop="0dp"/>
<Button
android:id="@+id/four"
android:layout_width="fill_parent"
android:layout_height="55sp"
android:text="@string/kanyikan"
android:background="#ffffff"
android:drawableLeft="@drawable/kanyikan_1"
android:gravity="left|center"
android:textSize="20sp"
android:layout_marginTop="12dp"
/>
<Button
android:id="@+id/five"
android:layout_width="fill_parent"
android:layout_height="55sp"
android:text="@string/souyisou"
android:background="#ffffff"
android:drawableLeft="@drawable/search"
android:gravity="left|center"
android:textSize="20sp"
android:layout_marginTop="0dp"
/>
<Button
android:id="@+id/six"
android:layout_width="fill_parent"
android:layout_height="55sp"
android:text="@string/fujinderen"
android:background="#ffffff"
android:drawableLeft="@drawable/fujinderen"
android:gravity="left|center"
android:textSize="20sp"
android:layout_marginTop="12dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="40sp"
android:layout_marginTop="18dp"
android:orientation="horizontal"
>
<Button
android:id="@+id/bone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/weixin"
android:background="#ffffff"
android:drawableTop="@drawable/weixin_1"
android:gravity="bottom|center"
android:textSize="12sp"
android:layout_weight="1"/>
<Button
android:id="@+id/btwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/tongxunlu"
android:background="#ffffff"
android:drawableTop="@drawable/tongxunlu_1"
android:gravity="bottom|center"
android:textSize="12sp"
android:layout_weight="1"/>
<Button
android:id="@+id/bthree"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/faxian"
android:background="#ffffff"
android:drawableTop="@drawable/faxian"
android:gravity="bottom|center"
android:textSize="12sp"
android:layout_weight="1"/>
<Button
android:id="@+id/bfour"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/wo"
android:background="#ffffff"
android:drawableTop="@drawable/wo"
android:gravity="bottom|center"
android:textSize="12sp"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
评论页布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageButton
android:layout_width="320dp"
android:layout_height="160dp"
android:src="@drawable/tutwo"
android:contentDescription="@string/desc"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
>
<ImageView
android:id="@+id/touxiangone"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:src="@drawable/touxiangone"
android:contentDescription="@string/desc"/>
<TextView
android:id="@+id/wangmingone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/touxiangone"
android:text="@string/wangmingone"
android:textColor="#576B95"
android:textSize="20sp" />
<TextView
android:id="@+id/contentone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/wangmingone"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/touxiangone"
android:minLines="2"
android:text="@string/contentone" />
<TextView
android:id="@+id/timeone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/touxiangone"
android:layout_marginTop="3dp"
android:text="@string/timeone"
android:textColor="#9A9A9A"
android:textSize="18sp"
android:layout_margin="3dp"/>
<Button
android:id="@+id/pinglun"
android:text="@string/pinglun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/contentone"
android:textSize="15sp"
android:background="#f8f8ff"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f0f8ff"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp">
<Button
android:id="@+id/btnone"
android:text="@string/wangmingtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#f8f8ff"/>
<ImageView
android:id="@+id/tupiancommentone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/comment"
android:layout_margin="2dp"
android:layout_toRightOf="@+id/btnone"
android:contentDescription="@string/desc"/>
<Button
android:id="@+id/btntwo"
android:text="@string/wangmingthree"
android:background="#f8f8ff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tupiancommentone"/>
<TextView
android:id="@+id/wenzicommenttwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/comment"
android:layout_margin="2dp"
android:minLines="2"
android:layout_below="@+id/tupiancommentone"
android:layout_toRightOf="@+id/btntwo"/>
</RelativeLayout>
</LinearLayout>
评论具体实现界面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/pinglunneirong"
android:textSize="32sp"
android:textColor="#c1d1c1"
android:layout_marginTop="130sp"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"/>
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="@string/shuru"
android:background="#f0f8ff"
android:textSize="40sp"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:layout_marginTop="15sp"/>
<Button
android:id="@+id/btntijiao"
android:text="@string/tijiao"
android:layout_width="70sp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="15sp"
android:layout_marginRight="30sp"
android:layout_marginTop="15sp"
/>
</LinearLayout>
资源文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">微信</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="pengyouquan">朋友圈</string>
<string name="faxian">发现</string>
<string name="saoyisao">扫一扫</string>
<string name="yaoyiyao">摇一摇</string>
<string name="kanyikan">看一看</string>
<string name="souyisou">搜一搜</string>
<string name="fujinderen">附近的人</string>
<string name="weixin">微信</string>
<string name="tongxunlu">通讯录</string>
<string name="wo">我</string>
<string name="wangmingone">生如夏花</string>
<string name="contentone">上善若水,水善利万物而不争,处众人之所恶,故几于道。</string>
<string name="timeone">昨天</string>
<string name="wangmingtwo">岁月静好:</string>
<string name="wangmingthree">随遇而安:</string>
<string name="comment">居善地,心善渊,与善仁,言善信,正善治,事善能,动善时。</string>
<string name="pinglun">评论</string>
<string name="desc">desc</string>
<string name="FriendActivity">发现</string>
<string name="pinglunneirong">请输入评论内容:</string>
<string name="shuru">输入:</string>
<string name="tijiao">提交</string>
<string name="PinglunActivity">评论</string>
<string name="tixing">提醒内容</string>
</resources>
主配置文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.weixin"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.weixin.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="FriendActivity"
android:label="@string/FriendActivity" >
</activity>
<activity
android:name="PinglunActivity"
android:label="@string/PinglunActivity" >
</activity>
<activity android:name=".InternalDataWriteActivity"/>
<activity android:name=".InternalDataReadActivity"/>
</application>
</manifest>
朋友圈到评论页跳转实现(点击朋友圈跳转)
package com.example.weixin;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnButton=(Button) findViewById(R.id.one);
btnButton.setOnClickListener(listener);
}
private OnClickListener listener=new OnClickListener(){
@Override
public void onClick(View v){
Intent intent=new Intent();
intent.setClass(MainActivity.this,FriendActivity.class);
startActivity(intent);
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
评论页到具体进行评论跳转(点击评论按钮跳转)
package com.example.weixin;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class FriendActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pinglunye);
Button btnButton=(Button) findViewById(R.id.pinglun);
btnButton.setOnClickListener(listener);
}
private OnClickListener listener=new OnClickListener(){
@Override
public void onClick(View v){
Intent intent=new Intent();
intent.setClass(FriendActivity.this,PinglunActivity.class);
startActivity(intent);
}
};
}
点击提交按钮回到评论页
package com.example.weixin;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class PinglunActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xiangxiye);
Button btnButton=(Button) findViewById(R.id.btntijiao);
btnButton.setOnClickListener(listener);
}
private OnClickListener listener=new OnClickListener(){
@Override
public void onClick(View v){
Intent intent=new Intent();
intent.setClass(PinglunActivity.this,FriendActivity.class);
startActivity(intent);
Toast.makeText(PinglunActivity.this, "亲,你有一条新的评论", Toast.LENGTH_LONG).show();
}
};
}