当SingleLine =“true”时,Android按钮停止“省略号”测试

时间:2013-12-30 23:57:59

标签: android android-button

正如标题所说,我想停止发生“省略号”,并显示与该按钮相关的整个字符串。我不明白为什么它没有显示字符串,而是它正在修剪它。

我知道“singleLine”会强制进行“修剪”,但我想把它放在一行中,而不是换行。我需要按钮在一行中显示它的小字符串,这就是全部。

我也尝试使用 minWidth maxWidth 无效。

在Android 2.3.6手机(Samsung Galaxy Mini)中查看布局时出现问题。

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".MainActivity"
    android:background="@drawable/background2" >

<ImageButton
    android:id="@+id/quote"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:layout_marginRight="24dp"
    android:contentDescription="@string/quote"
    android:background="#00000000"
    android:padding="30dp" />

  <ScrollView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="90dp" >
      <RelativeLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
           >

             <Button
                android:id="@+id/makeAMemory"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="80dp"
                android:layout_marginRight="70dp"
                android:text="@string/button_addMemory"
                android:singleLine="true"
                android:textColor="#E4F5ED"
                android:background="@drawable/button_shape_shadow" 
                android:padding="10dp"/>
             <Button
                android:id="@+id/fixMemory"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/makeAMemory"
                android:gravity="left"
                android:layout_marginTop="12dp"
                android:text="@string/button_fixMemory"
                android:textColor="#E4F5ED"
                android:background="@drawable/button_shape_shadow" 
                android:padding="10dp"
                android:onClick="startListViewMemoryActivity"/>
              <Button
                android:id="@+id/getMemory"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/fixMemory"
                android:gravity="left"
                android:layout_marginTop="12dp"
                android:text="@string/button_getMemory"
                android:textColor="#E4F5ED"
                android:background="@drawable/button_shape_shadow"  
                android:padding="10dp"/>

      </RelativeLayout>
  </ScrollView>

</RelativeLayout>

字符串是“Make memory”。这不长!非常感谢任何帮助。

EDITED

2 个答案:

答案 0 :(得分:0)

尝试添加:

android:ellipsize="none"

<强> EDITED

答案 1 :(得分:0)

最终这是有效的:

  1. 取出ScrollView
  2. android:layout_width
  3. 将RelativeView从“wrap_content”更改为“match_parent”
  4. 其余的保持不变
  5. 看起来像这样:

    <RelativeLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_centerHorizontal="true"
           android:layout_marginTop="90dp"
            >