2

Marquee 在 textview 中不起作用。我将 textview 放置在两个按钮之间的 TableLoyout 内。我将 textview 设置为可拉伸的列。这是我的xml代码。我无法弄清楚错误。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#e0bf64" android:orientation="vertical">


<TableLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="2"
    android:background="#f2cd6d">
    <TableRow>
        <Button 
            android:id="@+id/btn_prv" 
            android:text="@string/prv" 
            android:textSize="16sp" 
             android:layout_column="1"
            android:layout_width="100dip"               
            android:background="@drawable/prev_btn_re"
            android:paddingLeft="0sp"
            android:paddingTop="0sp"

        />

        <TextView 
            android:id="@+id/head_title" 
            android:layout_width="125dip"
            android:gravity="center"
            android:paddingLeft="5sp"
            android:paddingTop="10dip"
            android:paddingRight="0sp"
            android:background="#f2cd6d"
            android:textSize="16sp" 
            android:textColor="@color/black"
            android:marqueeRepeatLimit="marquee_forever"
            android:lines="1"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:freezesText="true"
            android:scrollHorizontally="true" 
            android:text="marquee text"

        />

        <Button 
            android:id="@+id/btn_next" 
            android:text="@string/next"
            android:textSize="16sp" 
            android:gravity="right"
            android:layout_width="100dip"
            android:background="@drawable/next_btn_re"
            android:paddingRight="10sp"
            android:paddingTop="5sp"
         />
      </TableRow>
   </TableLayout>
</LinearLayout>

请任何人告诉我为什么它不起作用?

4

1 回答 1

22

当 TextView 成为焦点或被选中时,选取框开始。您可以通过在 TextView 上调用 setSelected(true) 来强制它启动。

于 2011-12-12T19:31:39.910 回答