2015-02-23 120 views
0

我有一个按钮,它应像文本左对齐,右一个按钮

[1   44.33] 

,使文本对齐,同时左,右。

是否有可能实现它与一个单一的元素,没有介绍嵌套TextView s?

+0

它的一个单一的按钮或你想开关?如果你提供你想要的截图,那更好。 – 2015-02-23 11:13:30

+0

没有开关。 plain

+1

我不相信有任何标准的方法来做到这一点。但是,您可以在数字值之间添加内置选项卡,以便在单个按钮中始终保持它们之间的空间。 – 2015-02-23 11:14:29

回答

1

对于Button,您可以将ellipsize设置为middle并将singleLine设置为true

<Button 
      android:id="@+id/desc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="so that the text is aligned to left and right at the same time.Is it possible to achieve it with a single element, w/o introducing nested TextViews?" 
      android:textColor="#888686" 
      android:ellipsize="middle" 
      android:singleLine="true" 
      android:textSize="15dp" /> 
+0

抱歉,中间不应显示椭圆点。更新了我原来的问题 – injecteer 2015-02-23 12:37:07

1

是的,您可以检查按钮标签中的ellipsize元素。