首页 > 编程知识 正文

属性用于为embed元素设置资源,b站动态数据可视化工具

时间:2023-05-04 22:47:23 阅读:113932 作者:2646

因为网上很多SideBar写的是死亡的26个字符,所以不能根据名称动态显示。 自己更改,共享以供参考:

导入安卓. content.context; import android.graphics.Canvas; import android.graphics.Color; 导入安卓. graphics.paint; import android.graphics.Rect; import Android.graphics.typeface; 导入安卓. graphics.drawable.color drawable; import Android.util.attributes et; 导入安卓. view.motion event; 导入安卓. view.view; import Android .构件. textview; import com.qmuiteam.qmui.util.qmuidisplayhelper; import java.util.ArrayList; import java.util.Collections; import java.util.List; publicclasssidebarextendsview//触摸事件privateontouchingletterchangedlistenerontouchingletterchangedlistener; //26个字符的private String[] b={}; 私密int choose=-1; 检查隐私绘制点=新绘制点(; 隐私上下文m上下文; 隐私文本诊断程序; 私有浮动中心; 私密浮动项目高度; 私有列表tfloatlistheight=new ArrayList (; /jpdymjpdymjpdymsidebar显示字符的textviewjpdym @ parammtextdialogjpdym/publicvoidsettextview { textviewmtextdialog } { this } AttributeSet attrs,int defStyle ) super ) context,attrs,defStyle ); this.mContext=context; centery=qmuidisplayhelper.get screen height (m context )/2; itemHeight=centerY/27; }公共sidebar (xsd zxc,AttributeSet attrs ) (super ) context,attrs ); this.mContext=context; centery=qmuidisplayhelper.get screen height (m context )/2; itemHeight=centerY/27; }公共sidebar (xsd zxc ) super )上下文; this.mContext=context; centery=qmuidisplayhelper.get screen height (m context )/2; itemHeight=centerY/27; }私密int total height=0; 私密int textheight=0; /jpdymjpdym jpdym重写这一方的kkdsn/protectedvoidondraw (canvas canvas ) super.ondraw (canvas )。 if(b.length0) if ) Textheight=0) { Rect rect=new Rect; paint.gettextbounds(b[0],0,b[0].length ),rect ); textHeight=rect.height (; (} int width=getWidth ); //获取对应的宽度int center=b.length/2; setcentertext(canv

as, center, width, centerY); if (center > 0) { for (int i = center - 1; i >= 0; i--) { setCenterText(canvas, i, width, centerY - (center - i) jpdym 20 - itemHeight jpdym (center - i)); } for (int i = center + 1; i < b.length; i++) { setCenterText(canvas, i, width, centerY + (i - center) jpdym 20 + itemHeight jpdym (i - center)); } } Collections.sort(listHeight); totalHeight = (int) ((listHeight.get(listHeight.size() - 1)) - listHeight.get(0)); } } private void setCenterText(Canvas canvas, int i, int width, float yPos2) { paint.setColor(Color.parseColor("#666666")); paint.setTypeface(Typeface.DEFAULT); paint.setAntiAlias(true); paint.setTextSize(30); // 选中的状态 if (i == choose) { paint.setColor(Color.parseColor("#fc280c")); paint.setFakeBoldText(true); } // x坐标等于中间-字符串宽度的一半. float xPos1 = width / 2 - paint.measureText(b[i]) / 2; canvas.drawText(b[i], xPos1, yPos2, paint); if (!listHeight.contains(yPos2)) { listHeight.add(yPos2); } paint.reset();// 重置画笔 } @Override public boolean dispatchTouchEvent(MotionEvent event) { final int action = event.getAction(); final float y = event.getY();// 点击y坐标 final int oldChoose = choose; final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener; final int c = (int) ((y - listHeight.get(0)) / totalHeight jpdym b.length); switch (action) { case MotionEvent.ACTION_UP: setBackgroundDrawable(new ColorDrawable(0x00000000)); choose = -1;// invalidate(); if (mTextDialog != null) { mTextDialog.setVisibility(View.INVISIBLE); } break; default: // setBackgroundResource(R.drawable.sidebar_background); if (oldChoose != c) { if (c >= 0 && c < b.length) { if (listener != null) { listener.onTouchingLetterChanged(b[c]); } if (mTextDialog != null) { mTextDialog.setText(b[c]); mTextDialog.setVisibility(View.VISIBLE); } choose = c; invalidate(); } } break; } return true; } /jpdymjpdym jpdym 向外公开的方kkdsn jpdym @param onTouchingLetterChangedListener jpdym/ public void setOnTouchingLetterChangedListener( OnTouchingLetterChangedListener onTouchingLetterChangedListener) { this.onTouchingLetterChangedListener = onTouchingLetterChangedListener; } public void setData(String[] b) { this.b = b; invalidate(); } /jpdymjpdym jpdym 接口 jpdym jpdym @author coder jpdym/ public interface OnTouchingLetterChangedListener { public void onTouchingLetterChanged(String s); }}

使用高挑的康乃馨

//重写BaseQuickAdapter中的setList()高挑的康乃馨 override fun setList(list: Collection<ContactsBean>?) { val contactsList = list as MutableList<ContactsBean> Collections.sort(contactsList, PinyinContactsComparator()) if (null != slideBar && !contactsList.isNullOrEmpty()) { val tempList = mutableListOf<String>() for (bean in contactsList) { val sortStr = CharacterParser.getInstance().getSelling(bean.contactsName).substring(0, 1) .toUpperCase() if (!tempList.contains(sortStr)) { tempList.add(sortStr) } } //不加星号也可 tempList.add("#") slideBar.setData(tempList.toTypedArray()) } super.setList(contactsList) }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。