Reputation: 3674
I am using a simple spinner:
final SimpleCursorAdapter statusAdapter = new SimpleCursorAdapter(this,
android.R.layout.simple_spinner_item, null,
new String[] { "_id" }, new int[] { android.R.id.text1 }, 0);
statusAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
statuseSpinner.setAdapter(statusAdapter);
There is android:ellipsize="marquee"
attribute in both android.R.layout.simple_spinner_item
and android.R.layout.simple_spinner_dropdown_item
. But I don't see any marquee animation when text is long.
As I read in this link, I should call setSelected(true)
in textView. So I extend a custom adapeter and here is bindView
method:
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView textView = (TextView) view
.findViewById(android.R.id.text1);
textView.setText(cursor.getString(0));
textView.setSelected(true);
}
But It didn't solve the problem. So how can I have marquee with spinner?
Upvotes: 1
Views: 2590
Reputation: 11194
Thats true that android.R.layout.simple_spinner_item contains android:ellipsize="marquee" here but there are other attributes also you need to define in android xml below id code snip :
row.xml
<LinearLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:textStyle="bold"/>
</LinearLayout>
Upvotes: 1