前言Android中当文本显示不全时可以通过设置跑马灯方式轮播显示所以文字但是我们有时希望在指定情况下才启用跑马灯轮播,这就需要重写TextView来实现自定义跑马灯public class MarqueeText extends AppCompatTextView { private static final String TAG = "MarqueeText"; public MarqueeText(Context context) { super(context); } public MarqueeText(Context context, Attr
前言Android中当文本显示不全时可以通过设置跑马灯方式轮播显示所以文字但是我们有时希望在指定情况下才启用跑马灯轮播,这就需要重写TextView来实现自定义跑马灯public class MarqueeText extends AppCompatTextView { private static final String TAG = "MarqueeText"; public MarqueeText(Context context) { super(context); } public MarqueeText(Context context, Attr
一、前言笔者最近致力于vivo游戏中心稳定性维护,在分析线上异常时,发现有相当一部分是由OutOfMemory引起。谈及OOM,我们一般都会想到内存泄漏,其实,往往还有另外一个因素——图片,如果对图片使用不当的话,很容易吃掉大量内存,从而导致异常。尤其是游戏中心在2020末~2021初的几个重要版本,上线了很多内容相关的feature,引入大量图片、视频列表,从而导致线上OOM占比上升。在这篇文章中,笔者将讲解一张看似普通的Bitmap对内存的占用,介绍AndroidStudio中帮助我们分析图片占用内存的工具,举例说明流行的两大图片加载框架:Glide、Picasso在加载图片时使用内存的不
XML?xmlversion="1.0"encoding="utf-8"?>androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="
效果前言先来看一下ShapeableImageView是什么由上图可以看到ShapeableImageView也没有什么神秘的,不过是ImageView的一个子类而已,但是从效果图来看,在不写shape、不引入三方库的情况下,还是挺容易实现预期效果的,而且扩展性良好。使用引入material包implementation'com.google.android.material:material:1.2.1'常规android:layout_width="wrap_content"android:layout_height="wrap_content"an
一、前言笔者最近致力于vivo游戏中心稳定性维护,在分析线上异常时,发现有相当一部分是由OutOfMemory引起。谈及OOM,我们一般都会想到内存泄漏,其实,往往还有另外一个因素——图片,如果对图片使用不当的话,很容易吃掉大量内存,从而导致异常。尤其是游戏中心在2020末~2021初的几个重要版本,上线了很多内容相关的feature,引入大量图片、视频列表,从而导致线上OOM占比上升。在这篇文章中,笔者将讲解一张看似普通的Bitmap对内存的占用,介绍AndroidStudio中帮助我们分析图片占用内存的工具,举例说明流行的两大图片加载框架:Glide、Picasso在加载图片时使用内存的不
XML?xmlversion="1.0"encoding="utf-8"?>androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="
效果前言先来看一下ShapeableImageView是什么由上图可以看到ShapeableImageView也没有什么神秘的,不过是ImageView的一个子类而已,但是从效果图来看,在不写shape、不引入三方库的情况下,还是挺容易实现预期效果的,而且扩展性良好。使用引入material包implementation'com.google.android.material:material:1.2.1'常规android:layout_width="wrap_content"android:layout_height="wrap_content"an