65群组详情的布局(GridView和ScrollView一起使用的解决)
来源:互联网 发布:快3遗漏号码数据查询 编辑:程序博客网 时间:2024/06/06 17:59
想要实现的效果如下:
实现后:
稍微有点复杂:
看下整体的outline:
其实也不是很复杂,中间的分割线使用的是TextView,高度为1dp,屏幕群消息的两个按钮一个不可见,退出群聊和解散群聊的原理一样,GridView是自定义,这样可以避免ScrollView和GridView一起使用带来的问题。
核心代码:
<?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:background="#f2f0eb" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="@dimen/height_top_bar" android:background="@color/common_top_bar_blue" android:gravity="center_vertical" > <LinearLayout android:layout_width="45dp" android:layout_height="match_parent" android:background="@drawable/common_tab_bg" android:onClick="back" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="9dp" android:scaleType="centerInside" android:src="@drawable/our_group_back_on" /> </LinearLayout> <TextView android:id="@+id/group_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textColor="#ffffff" android:textSize="20sp" /> <ProgressBar android:id="@+id/progressBar" android:layout_width="26dp" android:layout_height="26dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="7dp" /> </RelativeLayout> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f2f0eb" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:orientation="vertical" > <com.dystu.impro.widget.ExpandGridView android:id="@+id/gridView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="13dp" android:background="@drawable/app_pref_bg" android:columnWidth="52dp" android:gravity="start" android:horizontalSpacing="6dp" android:listSelector="@android:color/transparent" android:numColumns="4" android:verticalSpacing="10dp" > </com.dystu.impro.widget.ExpandGridView> <TextView android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="#E6E6E6" /> <RelativeLayout android:id="@+id/clear_all_history" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="6dp" android:background="@drawable/btn_bottom_selector" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:gravity="center_vertical|left" android:paddingLeft="20dip" android:text="清空聊天记录" android:textColor="@android:color/black" android:textSize="18sp" android:typeface="serif" /> <TextView android:layout_width="match_parent" android:layout_height="1dip" android:layout_alignParentBottom="true" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="#E6E6E6" /> </RelativeLayout> <RelativeLayout android:id="@+id/rl_change_group_name" android:layout_width="match_parent" android:layout_height="50dip" android:layout_marginTop="6dp" android:background="@drawable/btn_bottom_selector" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:gravity="center_vertical|left" android:paddingLeft="20dip" android:text="改变群名称" android:textColor="@android:color/black" android:textSize="18sp" android:typeface="serif" /> <TextView android:layout_width="match_parent" android:layout_height="1dip" android:layout_alignParentBottom="true" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="#E6E6E6" /> </RelativeLayout> <RelativeLayout android:id="@+id/rl_blacklist" android:layout_width="match_parent" android:layout_height="50dip" android:layout_marginTop="6dp" android:background="@drawable/btn_bottom_selector" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:gravity="center_vertical|left" android:paddingLeft="20dip" android:text="黑名单列表" android:textColor="@android:color/black" android:textSize="18sp" android:typeface="serif" /> <TextView android:layout_width="match_parent" android:layout_height="1dip" android:layout_alignParentBottom="true" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="#E6E6E6" /> </RelativeLayout> <RelativeLayout android:id="@+id/rl_switch_block_groupmsg" android:layout_width="match_parent" android:layout_height="50dip" android:background="@drawable/btn_bottom_selector" android:padding="10dip" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:paddingLeft="10dip" android:text="屏蔽群消息" android:textColor="@android:color/black" android:textSize="18sp" android:typeface="serif" /> <ImageView android:id="@+id/iv_switch_block_groupmsg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:background="@drawable/open_icon" android:visibility="invisible" /> <ImageView android:id="@+id/iv_switch_unblock_groupmsg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:background="@drawable/close_icon" android:visibility="visible" /> </RelativeLayout> <TextView android:layout_width="match_parent" android:layout_height="1dip" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:background="#E6E6E6" /> <Button android:id="@+id/btn_exit_grp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="11dp" android:background="@drawable/btn_style_alert_dialog_special" android:onClick="exitGroup" android:paddingBottom="7dp" android:paddingTop="7dp" android:text="退出群聊" android:textColor="@android:color/white" android:textSize="18sp" /> <Button android:id="@+id/btn_exitdel_grp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="11dp" android:layout_marginRight="11dp" android:layout_marginTop="6dp" android:background="@drawable/btn_style_alert_dialog_special" android:onClick="exitDeleteGroup" android:paddingBottom="7dp" android:paddingTop="7dp" android:text="解散群聊" android:textColor="@android:color/white" android:textSize="18sp" android:visibility="gone" /> </LinearLayout> </ScrollView></LinearLayout>
自定义的GridView的代码:
package com.dystu.impro.widget;import android.content.Context;import android.util.AttributeSet;import android.widget.GridView;public class ExpandGridView extends GridView {public ExpandGridView(Context context, AttributeSet attrs) {super(context, attrs);}public ExpandGridView(Context context) {super(context);}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);super.onMeasure(widthMeasureSpec, expandSpec);}}
主要是解决高度的问题。
0 0
- 65群组详情的布局(GridView和ScrollView一起使用的解决)
- ScrollView和GridView滚动冲突的解决
- ScrollView和ListView一起使用的问题
- scrollview和gridview嵌套使用的注意事项
- PullToRefresh ScrollView的GridView和轮播图组合xml布局
- ScrollView和ListView一起使用 文本换行getMeasuredHeight等问题的解决
- 使ListView和其他的布局一起滑动(给ListView加ScrollView)
- GridView加载刷新连带单独的图片用(ScrollView和GridView)解决冲突
- 当ScrollView中内嵌GridView解决GridView和ScrollView重复滚动的问题
- 新闻详情页,scrollview view label 等控件的使用,以及页面布局
- ScrollView中有ListView和GridView的冲突解决
- 解决ScrollView嵌套ListView和GridView冲突的方法
- 解决ScrollView嵌套ListView和GridView冲突的方法
- 解决ScrollView嵌套ListView和GridView冲突的方法
- 解决ScrollView嵌套ListView和GridView冲突的方法
- 解决ScrollView嵌套ListView和GridView冲突的方法
- 解决ScrollView嵌套ListView和GridView冲突的方法
- 解决ScrollView和GridView嵌套时显示不全的问题
- Android JNI技术 实现自己的JNI_OnLoad函数案列
- linux3.x 内核如何强制卸载模块?
- 关于valgrind的安装和内存泄露分析
- lua 与 c++ 函数互调
- 进程线程调度方式
- 65群组详情的布局(GridView和ScrollView一起使用的解决)
- linux监控工具vmstat使用
- IntelliJ IDEA 偏好设置
- touch事件处理流程图
- iOS的主要框架介绍
- STL入门第四篇——唯美主义的杰作
- 多线程学习笔记(一)
- iOS 选择tableViewCell中的控件确定cell位置
- 从几个指标谈windows内存