mUnitNameTextView.setText(mCaseModel.getUnitName() == null ? "" : mCaseModel.getUnitName()); //开启线程获取行数,进行判断和设置对齐方式 mUnitNameTextView.post(() -> { if (mUnitNameTextView.getLineCount() > 1) //多余一行左对齐 mUnitNameTextView.setGravity(Gravity.LEFT); else //一行右对齐 mUnitNameTextView.setGravity(Gravity.RIGHT); });
TextView单行右对齐,换行左对齐实现,在此记录
最新推荐文章于 2024-06-24 14:44:27 发布