angcyo / DslTabLayout

:hearts: Android界最万能的TabLayout(不仅仅是TabLayout), 支持任意类型的item, 支持Drawable类型的指示器,智能开启滚动,支持横竖向布局等
https://github.com/angcyo/DslAdapter
MIT License
1.57k stars 148 forks source link

Tab 文本加粗样式在部分机型不生效问题 #77

Closed karlo0820 closed 1 year ago

karlo0820 commented 2 years ago

dslTabLayout 版本: 3.2.5 dslTabLayout xml样式设置如下: 1.设置 app:tab_enable_text_bold="true" 效果 2.在三星手机上不生效,在华为手机上有效

<com.angcyo.tablayout.DslTabLayout
    android:id="@+id/filter_tab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/dp_30"
    android:paddingBottom="@dimen/dp_15"
    app:layout_constraintEnd_toStartOf="@id/found_search_btn"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:tab_deselect_color="@color/color_5B5B5B"
    app:tab_enable_text_bold="true"
    app:tab_item_auto_equ_width="false"
    app:tab_text_max_size="@dimen/sp_16"
    app:tab_text_min_size="@dimen/sp_16"
    app:tab_select_color="@color/color_0f0f0f">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingStart="@dimen/dp_18"
        android:paddingEnd="@dimen/dp_16"
        android:text="全部" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingStart="@dimen/dp_16"
        android:paddingEnd="@dimen/dp_16"
        android:text="最新" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingStart="@dimen/dp_16"
        android:paddingEnd="@dimen/dp_16"
        android:text="最热" />
angcyo commented 2 years ago

3.3.0调整了变粗调用的api, 你试一下.

karlo0820 commented 2 years ago

还是不生效的

angcyo commented 2 years ago

还是不生效的

那你试一下, 能自绘出加粗效果的文本么?

karlo0820 commented 1 year ago

//文本加粗 paint?.apply { if (tabEnableTextBold && select) { // flags = flags or Paint.FAKE_BOLD_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG // isFakeBoldText = true this.typeface = Typeface.defaultFromStyle(Typeface.BOLD) } else { // flags = flags and Paint.FAKE_BOLD_TEXT_FLAG.inv() // isFakeBoldText = false this.typeface = Typeface.defaultFromStyle(Typeface.NORMAL) } }

确认下以这种方式设置粗体是否对项目其他效果会产生影响? @angcyo

angcyo commented 1 year ago

不会

karlo0820 commented 1 year ago

考虑下库中设置粗体能采用这种方式设置,出个新版本? @angcyo

angcyo commented 1 year ago

3.5.3 app:tab_use_typeface_bold="true"