Create animation for text field - android

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);

Related

How can I draw text on a text view bottom up?

I need to draw text on a TextView in a bottom up fashion, i.e., draw the last line of the text first at the bottom, then the second last line of the text and so on. How can I do that?
I am trying to follow the solution given in this post - Paginating text in Android.
TextView draws the text top down. What I want to achieve is given a text, I would like the last line of the view filled first, then the second last line and so on, Hence filling the first line in the last iteration. I tried creating a Custom TextView and overriding its onDraw method, but nothing seems to work.
Create a custom textview. In the setText method, do some string manipulation. Basically rearranging the text in the string so that the first line I the new text string is the last line of the old text string. Pass the new text string to the super.setText
If it is not scrollable textview you can set android:gravity="bottom|left" or "bottom|right" if you want right alignment. With this method width and hight can't be wrap_content.

Two text views with no margin(spacing)

I would like to achieve something like this:
I need that these two texviews would not have space between them. I specify no margin to them, but android already has a little bit margin by default and makes a little bit space. I would like to shrink that space :)
you can give negative margin to view.
Set same background for both TextView
You can specify Minus Margin like android:marginLeft=-5dp for Right side TextView or android:marginRight=-5dp for Left side TextView.
Thanks.
Try to create a second TextView inside the First one like
In XML, create a Second TextView like:
android:layout_alignBottom="#+id/firstTxtView"
android:layout_alignRight="#+id/firstTxtView"
android:layout_alignTop="#+id/firstTxtView"
try to set TextView's background #0000(transparent).
try to set margin left=-5dp or something to second TextView

Android XML: Good examples to use gravity rather than layout_gravity

I have done some basic xml layout from the Internet and I am confused as to what android:gravity would be used for vs android:layout-gravity. The UI designer seems to respond well when I change the layout_gravity, but I get no response to the regular gravity? What is up with this?
Is this similar to layout parameters with fill-parent and match-parent? one is gone now.
android:gravity is a statement from a parent to its content, indicating where the content should slide within the available parent space (if there is room for such sliding).
android:layout_gravity is a request from a child to its parent, asking that it be slid in a certain direction (if there is room for such sliding).
layout_gravity - It contains and it belongs to component's parent layout. Like if you set one TextView in LinearLayout, LinearLayout's width is fill_parent, but TextView basically will set at left-top. So now if you would give layout_gravity=right then your TextView will be shifted to top-right corner. But the text will not change its place. i.e. you had been wrote "Hello world" then "hello world" will not be changed to right, but its parent textView will be changed to right. So here in this case it will belongs to LinearLayout, means parent Layout.
gravity- It contains and it belongs to TextView as per above explanation. if you will give gravity="right" then "Hello-world" text will go to right-top corner of TextView not LinearLayout.

Align the start of the text in EditText and TextVIew

I have a simple layout in a table that consists of 3 rows. The second column may have either an EditText or a TextView like in the picture below:
Now, my question is how can I align the start of the text in EditText and TextView so that they are visually under each other (the texts, not the controls)? In the image above, the text in the second line starts too much to the left. I don't want to hardcode the padding as it may not work the same way on different devices.
try setting a padding for the second textview.
android:padding="5dp"
Instead of making the TextView match the EditText, make the EditText match the TextView by making its background null:
<EditText ... android:background="#null" ... />
The underline in the EditText then goes away and everything lines up perfectly.

How to keep EditText from breaking to the next line when width does not match_parent?

I am trying to fit two EditTexts horizontally. What I am trying to accomplish is make the text keep scrolling right without the EditText extending in anyway when there is no more space in that specific EditText. This happens when the EditText is set to match_parent (width), but when I set an actually width or wrap_content, it breaks to the next line. Not the behavior I am hoping for. Any ideas?
If I understood your question correctly, you're saying you want the edit text to be a single line each? If so, have you tried using the xml attribute
android:singleLine
Or you can accomplish the same thing with:
setSingleLine() //called on the edit text
I just tested it out with 2 edit texts in a horizontal linear layout set to 100dp width each and I think it accomplishes the behavior you want.
You can try this:
Set both to fill_parent and layout_weight=1. This will align them side by side.

Categories

Resources