android仿朋友圈

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>


3.listview_item.xml
<?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);
    }
}

源码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值