TextView setTextSize 需要传递单位

This commit is contained in:
yangyakun
2022-11-22 21:35:22 +08:00
parent a15ba31cef
commit b5f41184da
2 changed files with 7 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ import android.graphics.Point;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -219,13 +220,13 @@ public class TaxiPersonalDialogFragment extends
TextView textView = (TextView) tab.getCustomView().findViewById(R.id.operation_tab_title);
ImageView imageView = (ImageView) tab.getCustomView().findViewById(R.id.operation_tab_line_iv);
if (isSelected){
textView.setTextSize(AutoSizeUtils.dp2px(getContext(),46));
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,AutoSizeUtils.dp2px(getContext(),46));
CallerLogger.INSTANCE.d(M_TAXI + TAG,"SelectTv = "+ textView.getText());
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
textView.setTextColor(Color.parseColor("#FFFFFF"));
imageView.setImageDrawable(getResources().getDrawable(R.drawable.taxi_driver_operation_tab_line));
}else {
textView.setTextSize(AutoSizeUtils.dp2px(getContext(),40));
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,AutoSizeUtils.dp2px(getContext(),40));
CallerLogger.INSTANCE.d(M_TAXI + TAG,"unSelectTv = "+ textView.getText());
textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
textView.setTextColor(Color.parseColor("#A7B6F0"));

View File

@@ -6,6 +6,7 @@ import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;
@@ -27,6 +28,7 @@ import com.mogo.och.taxi.bean.OrderQueryRouteInfoRespBean;
import java.util.ArrayList;
import java.util.List;
import me.jessyan.autosize.AutoSize;
import me.jessyan.autosize.utils.AutoSizeUtils;
/**
@@ -136,13 +138,13 @@ public class TaxiServerOrdersFragment extends BaseTaxiUIFragment {
TextView textView = (TextView) tab.getCustomView().findViewById(R.id.tab_title);
if (isSelected){
textView.setBackground(getActivity().getDrawable(R.drawable.taxi_driver_tab_item_bg));
textView.setTextSize(AutoSizeUtils.dp2px(getContext(),40));
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,AutoSizeUtils.dp2px(getContext(),40));
CallerLogger.INSTANCE.d(M_TAXI + TAG,"SelectTv = "+ textView.getText());
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
textView.setTextColor(Color.parseColor("#FFFFFF"));
}else {
textView.setBackground(null);
textView.setTextSize(AutoSizeUtils.dp2px(getContext(),36));
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,AutoSizeUtils.dp2px(getContext(),36));
CallerLogger.INSTANCE.d(M_TAXI + TAG,"unSelectTv = "+ textView.getText());
textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
textView.setTextColor(Color.parseColor("#CCD4F5"));