1.仿朋友圈布局,效果图,内容很简单,直接上代码
2.activity_main.xml
<?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">
<LinearLayout
android:paddingLeft="10dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#ffffff"
android:orientation="horizontal">
<TextView
android:layout_marginLeft="10dp"
android:id="@+id/tv_titletop"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="动态" />
</LinearLayout>
<ListView
android:divider="#ffffff"
android:dividerHeight="0dp"
android:id="@+id/lv_dongtai"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></ListView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="10dp" />
<LinearLayout
android:background="#ffffff"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:padding="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="30dp">
<ImageView
android:id="@+id/iv_userpic"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:id="@+id/tv_username"
android:textSize="12sp"
android:gravity="center_vertical"
android:text="隔壁老王"
android:layout_width="wrap_content"
android:layout_height="15dp" />
<TextView
android:layout_gravity="center_vertical"
android:id="@+id/tv_pingluntime"
android:textSize="12sp"
android:layout_marginRight="10dp"
android:text="2017.11.30"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/tv_pingluncontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="此用户没有评价,72小时后默认好评。" />
<LinearLayout
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:id="@+id/ll_picture"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_zan"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="40dp">
<TextView
android:text="赞"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/ll_userpic"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="40dp">
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_marginLeft="3dp"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<ImageView
android:src="@mipmap/arrow_right"
android:layout_width="wrap_content"
android:layout_height="15dp" />
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:id="@+id/iv_shoucang"
android:src="@mipmap/icon_xin_empty"
android:layout_width="wrap_content"
android:layout_height="15dp" />
<TextView
android:id="@+id/tv_shoucang_count"
android:layout_marginLeft="10dp"
android:text="954"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
4.Myadapter
package com.example.mama.testdemo;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* Created by dingkangkang on 2017/12/1.
*/
public class Myadapter extends BaseAdapter{
Context context;
public Myadapter(Context contexts){
context=contexts;
}
@Override
public int getCount() {
return 30;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = LayoutInflater.from(context).inflate(R.layout.listview_item,null);
return convertView;
}
}
5.MainActivity
package com.example.mama.testdemo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
private ListView lv_dongtai;
private Myadapter myadapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv_dongtai = (ListView) findViewById(R.id.lv_dongtai);
myadapter = new Myadapter(this);
lv_dongtai.setAdapter(myadapter);
}
}