This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a way to make ellipsize=“marquee” always scroll?
I have a dynamic layout wich has one to six TextViews. All the TextViews are created in the Activity (programatically) and all are created equally.
I want to marquee the text in the TextViews, but I don't know how to do it. Apparently, the TextView needs to be focused for the marquee works fine, but how i focus six TextViews at the same time? I think that's not possible, so, is there any workaround? Is it possible to get the marquee working without having the focus?
This is the code of the TextViews:
//TextView
TextView tvTitulo = new TextView(this);
tvTitulo.setText("Some loooooooooooooooooooooong text");
tvTitulo.setTypeface(null, Typeface.BOLD);
//Marquee
tvTitulo.setSingleLine();
tvTitulo.setEllipsize(TruncateAt.MARQUEE);
tvTitulo.setHorizontallyScrolling(true);
tvTitulo.setFocusableInTouchMode(true);
If I remove the line tvTitulo.setFocusableInTouchMode(true); the marquee is not working at all.
If I don't remove the line, only one of the TextViews is getting the marquee working.
Greetings
Make tour TextView Selected add this line of code
tvTitulo.setSelected(true);
now more than one TextView marquee will works.
Related
Hello i am trying to display the content i receive in an activity using TextView but it seems that TextView is overlapping a button that i have put in activity's UI.My goal is to put TextView and the button side by side. I have put the TextView in the UI dynamically like this:
String display = extras.getString("EXTRA_MESSAGE");
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setWidth(20);
textView.setHeight(20);
textView.setText(display);
setContentView(textView);
I know i miss something but i cant find what it is,so can you please suggest a way how to fix that?
Thanks a lot in advance!
When you call setContentView(textView); it changes your layout to just the textView so it isn't overlapping your Button but your Button isn't shown anymore. You need to add it to your layout and put it where you want it.
You can do this by getting a reference to your root View in your xml and calling addView(textVie) on that root View and use addRule() to position your TextView where you want. However, if it isn't necessary to add your TextView dynamically then it is much easier to declare it in your xml.
If you do want to add it dynamically still, then this SO answer, and many more, covers it.
This question already has answers here:
creating a strikethrough text?
(14 answers)
Closed 9 years ago.
I wanna achieve an horizontal line that strikes a whole view inside a ListView, so I give the effect of striking the whole element in the listview.
How can I achieve this? I have found how to make a line below the view, but not over it.
This will create a strike out line on your view
<View
android:id="#+id/View_Strike"
android:layout_width="match_parent"
android:layout_below="#id/Layout_myRow"
android:layout_height="1dp"
android:background="#android:color/white" />
Now where you are designing a row layout for your listview. place this above view in such a way that it overlaps you Text View at the desired position in you Row Layout
and set its visibility Gone
Now depending on the Situation when you have to strike thru Your Item make its Visibility Visible
Surely is the solution !! i have used it in one of my app
Don't think there is a standard fast way of doing such a thing, but you can always create a view of fill_parent width and 1dp height and strike the whole view centering it relative to its parent.
make your custome view like stike image and make visible invisible as per your requirment over the current view
I have found the answer, if someone founds this useful:
Create a FrameLayout, inside of it I put the LinearLayout (with my TextViews) inside of it, and then a View with height=1dp width=fill_parent, and gravity of center.
The FrameLayout actually was created to make multiple layer views so it was the perfect thing.
Also for the details, in the listAdapter I make the View visible or gone.
I want to know if it's possible to create TextView marque verticaly in Android widget. i already try with horizontal but i want my textview marquee by verticaly.
Already googling for several hour but not find something usefull i can use..
Any suggestion ?
Try this one-->
Add these tags inside your <TextView>
android:ems = "1"
android:multipleLine = true
I need to create an animation in Android. I have 3 TextViews placed in an LinearLayout. All I want to do is the text field must come on to the screen as though it has been pulled out from the left end of the screen. Something similar to a marquee, however the text field must come from left end of screen one character at a time to occupy the left end of screen.
you must textView set textview property in your xml layout android:ellipsize="marquee" and you oncreate() method to set textview like youtextview.setSelected(true); now your textview running with marquee effect perfectly work for me!
another way you can add dynamically textview in coding you can follow this code:
yourtextview.setEllipsize(TruncateAt.MARQUEE);
yourtextview.setSelected(true);
I have created some TextView in the view ml, about 5 of them. But the problem is that after I read from xml file the values come, more than 5 sometimes, and there is no limit. It could be better more than 10. However if I can create the TextView from the activity, then I think I can do it somehow.
Assuming you want it add to a view called containingView,
TextView myTextView = new TextView(containingView.getContext());
myTextView.setText("alshareef");
containingView.addView(myTextView);