android studio的textview每行右边总留有空格

新手上路,请多包涵

2020-02-09 14 28 36.jpg

如上图所示,蓝色边框所选中的控件是一个textview,在第一行到“负一层”明明就已经结束了,但后面却跟了几个明显的空格(连同下面几行都跟着空格),导致整个控件偏大,压缩了右边的控件,这是怎么回事呢?看上去有点像word那种“为了不让一个单词从中间被换行而宁愿让该行少放一个单词并且留白右侧”的做法。但我这里用的都是中文,为什么会有这种现象呢?

另外还有个问题,为什么我3个控件的layout_weight都设置为1了,可他们的大小却明显看起来不一样呢?

代码如下:

<LinearLayout  
  android:layout\_width\="match\_parent"  
  android:layout\_height\="120dp"  
  android:layout\_marginStart\="15dp"  
  android:layout\_marginTop\="15dp"  
  android:layout\_marginEnd\="15dp"  
  android:layout\_marginBottom\="15dp"  
  \>  
  
    <TextView  
  android:layout\_width\="wrap\_content"  
  android:layout\_height\="wrap\_content"  
  android:text\="下单日期:2019-11-30\\n\\n预计到货:\\n2019-12-02"  
  android:layout\_weight\="1"  
  android:singleLine\="false"  
  />  
  
    <TextView  
  android:layout\_width\="wrap\_content"  
  android:layout\_height\="wrap\_content"  
  android:text\="松山湖深城投3号楼管井门扇(4191130-00249)\\n\\n\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\\n父项目:松山湖深城投\\n(0190831-00047)"  
  android:layout\_weight\="1"  
  android:singleLine\="false"  
  android:breakStrategy\="high\_quality"  
  
  
  />  
  
    <TextView  
  android:layout\_width\="wrap\_content"  
  android:layout\_height\="wrap\_content"  
  android:text\="当前状态:已出货"  
  android:layout\_weight\="1"  
  android:singleLine\="false"  
  />  
  
  
</LinearLayout\>
阅读 2.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进