![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
自定义控件
痞子小小崔
QQ:962935348
展开
-
【自定义控件】EditText实现自动焦点(输入法的自动显示与隐藏)
效果EdiText默认不获取焦点,点击后进入输入模式,输入法弹出,获取焦点。当输入完成后,输入法隐藏,EditText自动清除焦点。实现1、先解决EditText自动获取焦点的问题,在父布局内添加 android:focusable="true" android:focusableInTouchMode="true"2、编写自定义EditTextpublic class EditText_AutoFocus extends androidx.appcompat.widget.AppCo原创 2020-06-10 11:16:02 · 486 阅读 · 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 · 735 阅读 · 0 评论 -
【自定义控件】RecyclerView实现自动滚动效果
MyRecyclerViewpublic 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 · 780 阅读 · 0 评论 -
RecyclerView跳转指定Position后将其置顶
MyLinearSmoothScrollerpublic class MyLinearSmoothScroller extends LinearSmoothScroller { public MyLinearSmoothScroller(Context context) { super(context); } @Override protected int getHorizontalSnapPreference() { return SNA原创 2020-05-30 09:01:41 · 198 阅读 · 0 评论 -
Android——RecyclerView宽高自适应填充
基础知识GridLayoutManager 继承于 LinearLayoutManager,是 RecyclerView 的布局管理器,主要为了实现宫格布局。GridLayoutManager.setOrientation(GridLayoutManager.VERTICAL) 或 HORIZONTAL 可以设置 RecyclerView 的延展方向,VERTICAL 便是指纵方向延展。n...原创 2020-04-28 14:46:37 · 4094 阅读 · 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 · 263 阅读 · 0 评论