老规矩 先上效果图

1542355190753.gif

附下Demo

如果想要实现抖音一样的评论功能,就要再列表dialog上面再弹出一个dialog.

那么问题来了:当评论的dialog弹出来的时候两个dialog就会被顶起,但是我们想要的是评论列表不要被顶起

给评论列表的dialog设置此方法即可

Window win = dialog.getWindow();

WindowManager.LayoutParams params = win.getAttributes();

win.setSoftInputMode(params.SOFT_INPUT_ADJUST_NOTHING);

添加依赖 版本根据你build版本来

implementation 'com.android.support:design:27.1.1'

自定义类:ListBottomSheetDialogFragment继承BottomSheetDialogFragment

/**

* @Author: 淘跑

* @Date: 2018/7/2 15:18

* @Use:

*/

public class ListBottomSheetDialogFragment extends BottomSheetDialogFragment {

@Override

public void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//给dialog设置主题为透明背景 不然会有默认的白色背景

setStyle(DialogFragment.STYLE_NO_FRAME, R.style.CustomBottomSheetDialogTheme);

}

/**

* 如果想要点击外部消失的话 重写此方法

*

* @param savedInstanceState

* @return

*/

@Override

public Dialog onCreateDialog(Bundle savedInstanceState) {

Dialog dialog = super.onCreateDialog(savedInstanceState);

//设置点击外部可消失

dialog.setCanceledOnTouchOutside(true);

//设置使软键盘弹出的时候dialog不会被顶起

Window win = dialog.getWindow();

WindowManager.LayoutParams params = win.getAttributes();

win.setSoftInputMode(params.SOFT_INPUT_ADJUST_NOTHING);

//这里设置dialog的进出动画

win.setWindowAnimations(R.style.DialogBottomAnim);

return dialog;

}

@Nullable

@Override

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

// 在这里将view的高度设置为精确高度,即可屏蔽向上滑动不占全屏的手势。

//如果不设置高度的话 会默认向上滑动时dialog覆盖全屏

View view = inflater.inflate(R.layout.fragment_item_list_dialog, container, false);

view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

getScreenHeight(getActivity()) / 2));

return view;

}

@Override

public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rv);

recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

recyclerView.setAdapter(new ItemAdapter(100));

view.findViewById(R.id.tv).setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

//弹出评论输入框

InputDialog inputDialog = new InputDialog(getActivity());

Window window = inputDialog.getWindow();

WindowManager.LayoutParams params = window.getAttributes();

//设置软键盘通常是可见的

window.setSoftInputMode(params.SOFT_INPUT_STATE_VISIBLE);

inputDialog.show();

}

});

}

private class ItemAdapter extends RecyclerView.Adapter {

private final int mItemCount;

ItemAdapter(int itemCount) {

mItemCount = itemCount;

}

@Override

public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

return new MyViewHolder(LayoutInflater.from(parent.getContext()), parent);

}

@Override

public void onBindViewHolder(MyViewHolder holder, int position) {

holder.text.setText(String.valueOf(position));

}

@Override

public int getItemCount() {

return mItemCount;

}

public class MyViewHolder extends RecyclerView.ViewHolder {

final TextView text;

MyViewHolder(LayoutInflater inflater, ViewGroup parent) {

super(inflater.inflate(R.layout.fragment_item_list_dialog_item, parent, false));

text = (TextView) itemView.findViewById(R.id.text);

}

}

}

/**

* 得到屏幕的高

*

* @param context

* @return

*/

public static int getScreenHeight(Context context) {

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

int height = wm.getDefaultDisplay().getHeight();

return height;

}

}

自定义布局文件 fragment_item_list_dialog

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/shape_round_white">

android:id="@+id/rv"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/tv"

android:layout_width="match_parent"

android:layout_height="40dp"

android:layout_gravity="center_horizontal"

android:background="#454545"

android:gravity="center"

android:text="假装这是输入框"

android:textColor="#FFFFFF"

android:textSize="25dp" />

item布局文件 fragment_item_list_dialog_item

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@+id/text"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="center"

android:padding="10dp"

android:textColor="@android:color/black" />

自定义样式style: CustomBottomSheetDialogTheme这里设置的是背景也是透明的

@android:color/transparent

@null

true

false

true

@android:color/transparent

false

adjustPan|stateHidden

动画

@anim/dialog_bottom_in

@anim/dialog_bottom_out

dialog_bottom_in.xml

android:duration="400"

android:fromYDelta="100%p" />

dialog_bottom_out

android:duration="400"

android:toYDelta="100%p" />

评论输入Dialog

/**

* @Author:淘跑

* @Date: 2018/11/14 17:20

* @Use:

*/

public class InputDialog extends Dialog {

public InputDialog(@NonNull Context context) {

super(context);

// super(context, R.style.CustomDialog);

init(context);

}

public Context mContext;

public View mRootView;

public void init(Context context) {

mContext = context;

mRootView = LayoutInflater.from(context).inflate(R.layout.dialog_input, null);

setContentView(mRootView);

Window window = getWindow();

WindowManager.LayoutParams params = window.getAttributes();

params.width = WindowManager.LayoutParams.MATCH_PARENT;

window.setAttributes(params);

window.setGravity(Gravity.BOTTOM);

}

}

评论输入Dialog 布局

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@+id/et"

android:layout_width="match_parent"

android:layout_height="80dp" />

mysql仿网易评论_Android仿抖音评论列表(加评论功能)/网易云音乐列表相关推荐

  1. Android仿抖音评论列表(加评论功能)/网易云音乐列表

    老规矩 先上效果图 1542355190753.gif 附下Demo TikTok 如果想要实现抖音一样的评论功能,就要再列表dialog上面再弹出一个dialog. 那么问题来了:当评论的dialo ...

  2. python爬网易云音乐评论最多的歌_使用Python爬一爬网易云音乐上那些评论火爆的歌曲...

    网易云音乐这款音乐APP本人比较喜欢,用户量也比较大,而网易云音乐之所以用户众多和它的歌曲评论功能密不可分,很多歌曲的评论非常有意思,其中也不乏很多感人的评论.但是,网易云音乐并没有提供热评排行榜和按 ...

  3. python爬虫网易云音乐评论最多的歌_使用Python爬一爬网易云音乐上那些评论火爆的歌曲...

    网易云音乐这款音乐APP本人比较喜欢,用户量也比较大,而网易云音乐之所以用户众多和它的歌曲评论功能密不可分,很多歌曲的评论非常有意思,其中也不乏很多感人的评论.但是,网易云音乐并没有提供热评排行榜和按 ...

  4. python爬虫网易云音乐评论最多的歌_Python3实战之爬虫抓取网易云音乐的热门评论...

    前言 之前刚刚入门python爬虫,有大概半个月时间没有写python了,都快遗忘了.于是准备写个简单的爬虫练练手,我觉得网易云音乐最优特色的就是其精准的歌曲推荐和独具特色的用户评论,于是写了这个抓取 ...

  5. 用python爬取网易云评论最多的歌_巧用Python爬取网易云音乐歌曲全部评论

    一.首先分析数据的请求方式 网易云音乐歌曲页面的URL形式为https://music.163.com/#/song?id=歌曲id号,这里我用Delacey的Dream it possible 为例 ...

  6. 解密网易云音乐评论js加密参数,实现分词处理制作词云图

    前言: 很多人都说网易云音乐的一条评论是一个故事, 细细一看的话, 你会发现有些评论确实很真, 很性情. 抓取网易云音乐评论主要涉及了参数的加密问题,这篇博客主要是剖析一下如何进行参数的加密以及解密剖 ...

  7. python爬取音乐并保存_Python爬取网易云音乐上评论火爆的歌曲

    前言 网易云音乐这款音乐APP本人比较喜欢,用户量也比较大,而网易云音乐之所以用户众多和它的歌曲评论功能密不可分,很多歌曲的评论非常有意思,其中也不乏很多感人的评论.但是,网易云音乐并没有提供热评排行 ...

  8. python文本挖掘与分析:歌曲《说散就散》网易云音乐平台用户评论分析

    一.准备工作: 1.python3.x 2.编辑器pycharm 3.requests,json,os,base64,codecs,AES,pymysql(存入什么样的数据库就用什么,也可以不用数据库 ...

  9. python爬虫网易云音乐评论最多的歌_Python网易云音乐评论爬虫,歌曲的全部评论...

    用过网易云音乐听歌的朋友都知道,网易云音乐每首歌曲后面都有很多评论,热门歌曲的评论更是接近百万或者是超过百万条.现在我就来分享一下如何爬取网易云音乐歌曲的全部评论,由于网易云音乐的评论都做了混淆加密处 ...

最新文章

  1. 大数据发展新契机:中国人工智能产业创新联盟在京成立
  2. linux文件系统的设计,基于Linux的文件系统设计.doc
  3. JAVA WEB篇3——JSP
  4. 怎么样获取浏览器“该页无法显示”这类的异常 - -
  5. B - Beautiful Paintings
  6. 2018-2019-2 20175228实验二《面向对象程序设计》实验报告
  7. momentjs 使用总结
  8. installanywhere's LAX Properties
  9. css布局Absolute的垂直水平居中
  10. java 微信 图灵机器人_SAE服务下用java实现微信公众账号图灵机器人
  11. 牙林一中2021年高考成绩查询,牙林一中2019高考成绩喜报、一本二本上线人数情况...
  12. win10笔记本 CMD命令直接开启热点(WIFI)
  13. java迭代器遍历json,批量替换内容
  14. 强大的头像制作神器_支持外卖CPS等优惠劵小程序源码
  15. imx6开发环境搭建之yocto全记录(L4.1.15_2.0.0)
  16. JS逆向必会基础案例 | 百度翻译参数破解
  17. 请问如何查看我的ubuntu是32位的还是64位的
  18. 两寸照片电子版怎么弄?教你一分钟搞定
  19. winXP procession秘钥
  20. 牛顿插值c语言分析作业,牛顿插值函数C语言程序实现

热门文章

  1. BeatSaber节奏光剑插件开发官方教程1-创建一个插件模板
  2. svga插件_如何压缩SVGA格式的礼物特效文件
  3. “给阿姨倒杯卡布奇诺”广发卡分期积分带你免费畅饮星巴克!
  4. Mac使用终端命令合并分区
  5. 前端面试-浏览器原理
  6. Aleo提高高算力的解决方法(精选)
  7. access团员人数公式_2015年3月全国二级ACCESS操作真题第1套
  8. dnn解读_论文学习+解读1--受优化算法启发的DNN网络设计
  9. c++知识点(高级)
  10. hfds下的文件导入hive表格