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

logohoo 2017-08-30 08:51:22
android studio打开编辑一个activity的xml布局时,计算机内存猛增2G直到卡死。
这是为什么啊?xml里面没有用到什么资源啊,只是布局大小?文件大小也不是很多7K。
请问这是为什么呢?删除xml再打开就不会。重新创建一个,再编辑也没有事,只是编辑完后保存,下次再打开,就猛增内存,直到计算机卡死。
...全文
484 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用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配置有没有问题,

80,471

社区成员

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

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