自定义控件
痞子小小崔
QQ:962935348
展开
-
【自定义控件】EditText实现自动焦点(输入法的自动显示与隐藏)
效果 EdiText默认不获取焦点,点击后进入输入模式,输入法弹出,获取焦点。 当输入完成后,输入法隐藏,EditText自动清除焦点。 实现 1、先解决EditText自动获取焦点的问题,在父布局内添加 android:focusable="true" android:focusableInTouchMode="true" 2、编写自定义EditText public class EditText_AutoFocus extends androidx.appcompat.widget.AppCo原创 2020-06-10 11:16:02 · 512 阅读 · 0 评论 -
【自定义View】自动滚动的TextView(跑马灯)——可获取完成一次滚动后的监听
AutoRollTextViewByRunnable类 class AutoRollTextViewByRunnable extends androidx.appcompat.widget.AppCompatTextView implements Runnable { String TAG = "MarqueeText"; private int currentScrollX = 0;// 当前滚动的位置 private int textWidth; private int原创 2020-07-18 01:24:07 · 765 阅读 · 0 评论 -
【自定义控件】RecyclerView实现自动滚动效果
MyRecyclerView public class MyRecyclerView extends RecyclerView { Handler mHandler = new Handler(); public MyRecyclerView(@NonNull Context context) { super(context); } public MyRecyclerView(@NonNull Context context, @Nullable Att原创 2020-05-30 09:08:50 · 787 阅读 · 0 评论 -
RecyclerView跳转指定Position后将其置顶
MyLinearSmoothScroller public class MyLinearSmoothScroller extends LinearSmoothScroller { public MyLinearSmoothScroller(Context context) { super(context); } @Override protected int getHorizontalSnapPreference() { return SNA原创 2020-05-30 09:01:41 · 208 阅读 · 0 评论 -
Android——RecyclerView宽高自适应填充
基础知识 GridLayoutManager 继承于 LinearLayoutManager,是 RecyclerView 的布局管理器,主要为了实现宫格布局。 GridLayoutManager.setOrientation(GridLayoutManager.VERTICAL) 或 HORIZONTAL 可以设置 RecyclerView 的延展方向,VERTICAL 便是指纵方向延展。 n...原创 2020-04-28 14:46:37 · 4213 阅读 · 0 评论 -
自适应文字大小的TextView
Android8.0以上可以在TextView中添加autoSizeTextType实现 Android8.0以下要想达到根据TextView大小自动调整文字大小(不适合使用多行文字),只能自定义了 public class PZHelp_TextView_AutoTextSize extends androidx.appcompat.widget.AppCompatTextView { ...原创 2020-04-16 11:46:18 · 287 阅读 · 0 评论