封版羽声,作为最后的基础版
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.tencent.qcloud.tuikit.timcommon.component;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -31,8 +30,6 @@ public class TitleBarLayout extends LinearLayout implements ITitleBarLayout {
|
||||
private ImageView mLeftIcon;
|
||||
private ImageView mRightIcon;
|
||||
private RelativeLayout mTitleLayout;
|
||||
private ImageView mLeftUserAvatar;
|
||||
private TextView mUserNickName;
|
||||
private UnreadCountTextView unreadCountTextView;
|
||||
|
||||
public TitleBarLayout(Context context) {
|
||||
@@ -50,7 +47,6 @@ public class TitleBarLayout extends LinearLayout implements ITitleBarLayout {
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
@SuppressLint("WrongViewCast")
|
||||
private void init(Context context, @Nullable AttributeSet attrs) {
|
||||
String middleTitle = null;
|
||||
boolean canReturn = false;
|
||||
@@ -75,9 +71,6 @@ public class TitleBarLayout extends LinearLayout implements ITitleBarLayout {
|
||||
mRightIcon = findViewById(R.id.page_title_right_icon);
|
||||
unreadCountTextView = findViewById(R.id.new_message_total_unread);
|
||||
|
||||
mLeftUserAvatar = findViewById(R.id.tab_icon);
|
||||
mUserNickName = findViewById(R.id.tab_nickname);
|
||||
|
||||
LayoutParams params = (LayoutParams) mTitleLayout.getLayoutParams();
|
||||
params.height = ScreenUtil.getPxByDp(50);
|
||||
mTitleLayout.setLayoutParams(params);
|
||||
@@ -177,22 +170,6 @@ public class TitleBarLayout extends LinearLayout implements ITitleBarLayout {
|
||||
return mLeftTitle;
|
||||
}
|
||||
|
||||
public TextView getmUserNickName() {
|
||||
return mUserNickName;
|
||||
}
|
||||
|
||||
public void setmUserNickName(TextView mUserNickName) {
|
||||
this.mUserNickName = mUserNickName;
|
||||
}
|
||||
|
||||
public ImageView getmLeftUserAvatar() {
|
||||
return mLeftUserAvatar;
|
||||
}
|
||||
|
||||
public void setmLeftUserAvatar(ImageView mLeftUserAvatar) {
|
||||
this.mLeftUserAvatar = mLeftUserAvatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextView getMiddleTitle() {
|
||||
return mCenterTitle;
|
||||
|
||||
@@ -65,32 +65,6 @@ public class UnreadCountTextView extends AppCompatTextView {
|
||||
canvas.drawRoundRect(new RectF(0, 0, getMeasuredWidth(), getMeasuredHeight()), getMeasuredHeight() / 2, getMeasuredHeight() / 2, mPaint);
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
|
||||
// 获取文本的宽度
|
||||
// float textWidth = getPaint().measureText(getText().toString());
|
||||
//
|
||||
// float unreadMarkerLeft = textWidth + dp2px(4);
|
||||
// float unreadMarkerTop = (getMeasuredHeight() - mNormalSize) / 2;
|
||||
// float unreadMarkerRight = unreadMarkerLeft + mNormalSize;
|
||||
// float unreadMarkerBottom = unreadMarkerTop + mNormalSize;
|
||||
//
|
||||
// if (getText().length() == 0) {
|
||||
// int l = (getMeasuredWidth() - dp2px(6)) / 2;
|
||||
// int t = l;
|
||||
// int r = getMeasuredWidth() - l;
|
||||
// int b = r;
|
||||
// canvas.drawOval(new RectF(l, t, r, b), mPaint);
|
||||
// } else if (getText().length() == 1) {
|
||||
// canvas.drawOval(new RectF(unreadMarkerLeft, unreadMarkerTop, unreadMarkerRight, unreadMarkerBottom), mPaint);
|
||||
// } else if (getText().length() > 1) {
|
||||
// canvas.drawRoundRect(
|
||||
// new RectF(unreadMarkerLeft, unreadMarkerTop, unreadMarkerRight + dp2px((getText().length() - 1) * 10), unreadMarkerBottom),
|
||||
// getMeasuredHeight() / 2,
|
||||
// getMeasuredHeight() / 2,
|
||||
// mPaint
|
||||
// );
|
||||
// }
|
||||
// super.onDraw(canvas); // ✅ 必须放在最后才能显示文本
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,22 +75,6 @@ public class UnreadCountTextView extends AppCompatTextView {
|
||||
width = mNormalSize + dp2px((getText().length() - 1) * 10);
|
||||
}
|
||||
setMeasuredDimension(width, height);
|
||||
|
||||
// 固定高度为 mNormalSize
|
||||
// int height = mNormalSize;
|
||||
//
|
||||
// // 计算文本宽度 + 未读标记宽度(包含间距)
|
||||
// float textWidth = getPaint().measureText(getText().toString());
|
||||
// float unreadMarkerWidth = mNormalSize + dp2px(4); // 未读标记 + 间距
|
||||
//
|
||||
// int width = (int) (textWidth + unreadMarkerWidth);
|
||||
//
|
||||
// // 如果是多个字符的计数(如 "99+"),增加额外宽度
|
||||
// if (getText().length() > 1) {
|
||||
// width += dp2px((getText().length() - 1) * 10);
|
||||
// }
|
||||
//
|
||||
// setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
private int dp2px(float dp) {
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/transparent"
|
||||
android:id="@+id/page_title_layout">
|
||||
|
||||
<LinearLayout
|
||||
@@ -45,25 +43,7 @@
|
||||
android:textColor="?attr/core_title_bar_text_bg"
|
||||
android:gravity="center"
|
||||
android:textSize="16.3sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tab_icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tab_nickname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="用户信息"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="8dp"/>
|
||||
|
||||
android:textStyle="bold"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -93,7 +73,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:visibility="gone">
|
||||
android:visibility="invisible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_title_right_text"
|
||||
|
||||
Reference in New Issue
Block a user