Reputation: 885
I am facing the following two related (?) problems:
Note that I am building an AlertDialog. Below is the code:
public class AboutFragment extends DialogFragment
{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
String message = "Top line message";
builder.setTitle(R.string.about_title);
View v = this.getActivity().getLayoutInflater().inflate(R.layout.about_scrollable,null);
TextView tv = (TextView) v.findViewById(R.id.about_txt_scr);
TextView tv2 = (TextView) v.findViewById(R.id.about_message);
tv2.setText(message);
tv.setSelected(true);
tv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv.requestFocus();
builder.setView(v);
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
//nothing really to be done here
}
});
return builder.create();
}
}
And the layout:
<?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:orientation="vertical">
<TextView
android:id="@+id/about_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="20dp"
android:paddingBottom="0dp"
/>
<TextView
android:id="@+id/about_txt_scr"
android:text="A really long text that is going on and on but it actually truncated using ellipsis in this example"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="0dp"
android:paddingBottom="20dp"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:textIsSelectable="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:lines="1"/>
</LinearLayout>
Upvotes: 0
Views: 1092
Reputation: 1340
try below attribute for your textview 'about_txt_scr'
<TextView
android:id="@+id/about_txt_scr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="A really long text that is going on and on but it actually truncated using ellipsis in this example" />
And comment this 2 lines from the from onCreateDialog method
//tv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
//tv.requestFocus();
Upvotes: 2