2012-01-18 65 views
3

以下の問題を修正しました。簡単な変更。 android:lines="1"android:singleLine="true"に置き換えました。Android 4.0(ISO)ウィジェットでTextViewマーキーが機能しない


現在、私のアプリはマーキーとしてウィジェットのテキストを表示しています。 4.0バージョン以外のすべてのAndroid OSで期待どおりに動作しています。 APIレベル14のエミュレータでテストしましたが、テキストはスクロールしません(マーキー)。以下は、マーキーエフェクトのテキストを表示するために使用されるレイアウトxmlです。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TextView 
    android:id="@+id/tv" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:lines="1" 
    android:background="@android:color/background_dark" 
    android:ellipsize="marquee" 
    android:fadingEdge="horizontal" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:textColor="@android:color/white" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:duplicateParentState="true" 
    android:textSize="20dp"> 
    <requestFocus android:focusable="true" android:focusableInTouchMode="true" 
     android:duplicateParentState="true" /> 
</TextView> 
</RelativeLayout> 

この問題を解決するお手伝いをしてください。

ありがとうございます。

+0

あなたのソリューションを下に追加し、それを受け入れ可能なものとしてマークすることができます。そうでなければ、質問を削除できます。 –

+2

私は以下の問題を修正しました。簡単な変更。 Android:lines = "1"をandroid:singleLine = "true"に置き換えました。 – sharmi

答えて

12

説明のため。

<TextView 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:duplicateParentState="true" 
    android:ellipsize="marquee" 
    android:fadingEdge="horizontal" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:singleLine="true" 
    android:text="@string/your_text"> 
    <requestFocus 
     android:duplicateParentState="true" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 
</TextView> 
+1

私はを知りませんでした。それは素晴らしいトリックです! –

+0

これはAndroid 2.2と4.1.2でテストされ、完璧に動作します! –

関連する問題