android studio编辑activity的xml布局内存猛增2G

logohoo 2017-08-30 08:51:22
android studio打开编辑一个activity的xml布局时,计算机内存猛增2G直到卡死。
这是为什么啊?xml里面没有用到什么资源啊,只是布局大小?文件大小也不是很多7K。
请问这是为什么呢?删除xml再打开就不会。重新创建一个,再编辑也没有事,只是编辑完后保存,下次再打开,就猛增内存,直到计算机卡死。
...全文
473 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
辉_alexxm 2017-09-07
  • 打赏
  • 举报
回复
楼主已测试到 protected void onDraw(Canvas canvas) while (textHeight > fontViewHeight) 这部分代码出错,应是死在这里!
辉_alexxm 2017-09-07
  • 打赏
  • 举报
回复
楼主的问题重新描述下,是运行还是编辑啊! 如何运行把相关代码也贴出来,或者提取一个有问题的APK源码出来,不要让人猜;
logohoo 2017-09-06
  • 打赏
  • 举报
回复
那么多人说上代码,上完一个人回都没有?怎么回事啊?人哪
logohoo 2017-09-05
  • 打赏
  • 举报
回复
麻烦帮帮忙,贴代码了,麻烦看下,谢谢。
logohoo 2017-09-04
  • 打赏
  • 举报
回复
去了就不会,麻烦帮忙看下什么问题?谢谢。
足球中国 2017-09-04
  • 打赏
  • 举报
回复
com.magicdun.app.WidgetsClass.AutoTextView 这个控件先换掉试试。
logohoo 2017-09-03
  • 打赏
  • 举报
回复
应该是AutoTextView问题,代码如下,麻烦看下 public class AutoTextView extends TextView { private int maxHeight; // public AutoTextView(Context context) { super(context, null); } public AutoTextView(Context context,AttributeSet attrs){super(context,attrs);} public AutoTextView(Context context,AttributeSet attrs,int defStyleAttr){super(context,attrs,defStyleAttr);} public AutoTextView(Context context,AttributeSet attrs,int defStyleAttr,int defStyleRes){super(context,attrs,defStyleAttr,defStyleRes);} // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); if(heightMode == MeasureSpec.AT_MOST) { maxHeight = MeasureSpec.getSize(heightMeasureSpec); } } protected void onDraw(Canvas canvas) { TextPaint paint = getPaint(); float textSize = getTextSize();; paint.setTextSize(textSize); if(maxHeight==0){maxHeight = getHeight();} float textViewHeight = maxHeight - getPaddingTop() - getPaddingBottom(); float fontViewHeight = textViewHeight - paint.getFontSpacing() * 2;//不包含左右字体空间 String text = getText().toString(); float textHeight = paint.measureText(text); while (textHeight > fontViewHeight) { textSize--; paint.setTextSize(textSize); textHeight = paint.measureText(text); fontViewHeight = textViewHeight - paint.getFontSpacing() * 2; } super.onDraw(canvas); } }
logohoo 2017-09-03
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/cl_white" android:orientation="vertical" > <RelativeLayout android:id="@+id/layout_message" android:layout_width="match_parent" android:layout_height="wrap_content"> <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_message" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="left|center" android:textColor="@color/cl_black"/> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/px_1" android:background="@color/cl_black"> </LinearLayout> <LinearLayout android:id="@+id/layout_up" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <RelativeLayout android:id="@+id/layout_w0" android:layout_width="@dimen/dp_0" android:layout_height="match_parent" android:padding="@dimen/dp_2" android:layout_weight="1" > <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_w0" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center" android:textColor="@color/cl_black"/> </RelativeLayout> <RelativeLayout android:id="@+id/layout_w1" android:layout_width="@dimen/dp_0" android:layout_height="match_parent" android:padding="@dimen/dp_2" android:layout_weight="1" > <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_w1" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center" android:textColor="@color/cl_black"/> </RelativeLayout> <RelativeLayout android:id="@+id/layout_w2" android:layout_width="@dimen/dp_0" android:layout_height="match_parent" android:padding="@dimen/dp_2" android:layout_weight="1" > <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_w2" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center" android:textColor="@color/cl_black"/> </RelativeLayout> <RelativeLayout android:id="@+id/layout_w3" android:layout_width="@dimen/dp_0" android:layout_height="match_parent" android:padding="@dimen/dp_2" android:layout_weight="1" > <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_w3" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center" android:textColor="@color/cl_black"/> </RelativeLayout> <RelativeLayout android:id="@+id/layout_w4" android:layout_width="@dimen/dp_0" android:layout_height="match_parent" android:padding="@dimen/dp_2" android:layout_weight="1" > <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_w4" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center" android:textColor="@color/cl_black"/> </RelativeLayout> <RelativeLayout android:id="@+id/layout_w5" android:layout_width="@dimen/dp_0" android:layout_height="match_parent" android:padding="@dimen/dp_2" android:layout_weight="1" > <com.magicdun.app.WidgetsClass.AutoTextView android:id="@+id/view_w5" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center|center" android:textColor="@color/cl_black"/> </RelativeLayout> </LinearLayout> </LinearLayout>
辉_alexxm 2017-08-30
  • 打赏
  • 举报
回复
xml 内容出错了,贴出来下!
莫卢俊德 2017-08-30
  • 打赏
  • 举报
回复
Androidstudio没有配置好
  • 打赏
  • 举报
回复
引用 4 楼 accessysq 的回复:
[quote=引用 3 楼 EX_Cj 的回复:] 这是不正常的,先把你的xml代码贴出来,检查一下你的gradle配置有没有问题,
捉住你了,哈哈[/quote]被抓住了
  • 打赏
  • 举报
回复
引用 3 楼 EX_Cj 的回复:
这是不正常的,先把你的xml代码贴出来,检查一下你的gradle配置有没有问题,
捉住你了,哈哈
  • 打赏
  • 举报
回复
这是不正常的,先把你的xml代码贴出来,检查一下你的gradle配置有没有问题,
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧