RelativeLayout android:clipChildren="false" does not work: Animation will get clipped? - android

I am trying to implement a scrolling "newsbar". There is a RelativeLayout which fills the screen horizontally. It should contain many different news titles, contained by TextView objects, which I download from the internet and they should be animated in order to slowly moving from right to left, which will generate a "scrolling newsbar" effect. I place the first TextView as RelativeLayout.ALIGN_PARENT_LEFT and all the consecutive TextViews aligned as RelativeLayout.RIGHT_OF according to the previous TextView. So, the text would enter from the right side of the screen and flow through the layout and finally exit from the left side.
I see that the RelativeLayout clips children which are outside of its bounds. I set android:clipChildren="false" for this purpose but it does not function and the TextViews continue to get clipped, which is very annoying and is currently blocking my progress.
Is this a bug or am I doing something wrong?
Please help me...

Related

Make a horizontal scrollview clickable at a specific spot?

I'm developing an App on Android Studio and I want to have an easter egg. To do this easter egg, I want people to click on the moon to unlock a new avatar.
The problem:
As you can see in the image, the background image is a whole horizontal scrollview and I can't make only a certain part of the horizontal view clickable. This leaderboard page shows up as it is shown on the schema 1 so if you move your finger in the arrow direction, you'll end up on the schema 2, because you've scrolled all the way to the left of the image.
What i've tried:
I tried do put the ImageButton inside de image scrollview, I tried to put the ImageButton inside the scrollview after and before the background image, I tried to put it outside the scrollview, after and before also, I tried to put a scrollview inside the existing scrollview, again, after and before the image.
My question:
How can I make it so that only the moon on the whole scrollview is clickable? Or is there a away to go around this problem and do this by other means? All help is acceptable, thanks!

Why is not working my horizontal scrolling done programmatically?

I'm trying to make horizontal scroll in TextView bRes programmatically. Reading some answers and tutorials, I've included some settings.
bRes.setHorizontallyScrolling(true)
bRes.setMaxLines(1)
bRes.setMovementMethod(ScrollingMovementMethod())
bRes.setScroller(Scroller(this))
I put in the left and right side of TextView, small left and arrows black triangles with a click event to make right and left scroll if text width surpasses the view width. The buttons just appears if they has some action to do.
When I set the text in TextView, I call this code
fun changeRes(t:String){
bRes.text = t
bRes.post{ bRes.scrollTo(0,0) }
val largu = bRes.getPaint().measureText(t)
bRight.visibility = if (largu > 0.99 * bRes.width)
View.VISIBLE else View.INVISIBLE
bLeft.visibility = View.INVISIBLE
}
I've selected put the text excess in the right side, i,e, when the text is wider than TextView, the left black arrow is invisible and the right black triangle is visible.
Well, with this the text disappears completely. If I comment the line
bRes.post{ bRes.scrollTo(0,0) }
the text appears again, but there is no scroll. I don't get to see the left excess characters. The bRes.scrollX value should by 200/300 pixes but is over 1 million!
The first parameter, according documentation, is the number of pixels invisible to left of the TextView.
PS: I've used exactly the same procedure to program a vertical scroll in another TextView and it works very well. I don't use ScrollView, I've directly programmed a scrolling in my another TextView.
PS 2: I've created all my layout dinamically. No XML for layouts.
Somebody has some help for me?
I have no idea about it, except put the text in TextView manually in each change.
What kind of layout are you using? It should not be a LinearLayout, but rather a FrameLayout or RelativeLayout
I've made a workaround that is working very well for me. It's sad that I haven't found a more direct way to do this:
a) I've put 2 triangle arrows inside 2 small buttons to the left and rigth of TextView.
b) The buttons are visible or not depending if has or not scroll hidden text in its respective direction.
c) I've used the event OnTouchListener to accept click in the scroll buttons or 20% of TextView width nearest to each arrow for getting more hidden text in that direction (I've made this because the arrows are small and prone to touching in a wrong place.
d) I have to keep inside a tag (extra field of the widget) a complete text value of the widget.
e) For calculating which text I have to put in a field, I've programmed a heuristic using
widget.getPaint().measureText(string)
The visual is something like this:
PS: The ideal isn't using horizontal scroll, but if it is necessary, I think that the above appearance is nice and it is practical for users. I don't like the marquee solution where text moves alone: thinking as user, it's annoying.

Scroll linear layout beyond the content

I think that this is a simple question but I can't figure it out, I have a Scroll View with some text inside and it works perfectly, it only enables scrolling when the content doesn't fit into the screen. The thing is that I want to scroll the content no matter if it fits or not until the last line of the text reach the top of the view leaving blank space below and obviously "hiding" the content above it. I don't know if I'm explaining myself very well, thanks in advance!
Add a dummy view with height equal to the height of device's screen beneath your textview in scrollView.

Android - keeping a single element contained on screen

I'm experimenting to see if the layout scheme I want to use is possible. I want to have an XML layout that's scrollable. Within that scrollable layout, I want to have a single line going horizontally across the screen (I used just a View with a fixed height and different color). When that horizontal line reaches the top of the screen, and as I scroll down through the layout, I want it to stop and remain at the top of the screen while being able to scroll through everything below it.
I've been messing around in XML trying to get it to work, basically putting a bunch of junk before it and after it.
Any ideas as to how that might work? Would I have to do something fancy with the java code to fix the red line at the top when the scroll position reaches a certain point? Your help would be greatly appreciated.
I am assuming you want something like Gmail app where when you scroll a mail the header sticks on top... To do this, you need 2 views. You have your regular scroller below and overlay a fixed view on top (you can use a relative layout to do this). When your cell goes past a certain spot, you want to populate and set the visibility of the fixed view to VISIBLE. This would give the impression that the view you want to 'stick' to the top really just got stuck rather than scrolled out of view. You'll have to work out the opposite scrolling scenario too based on the location and height of the scrolled cell/view.
HTH

Android: Keeping Image Visible Throughout Animation

Background:
I have an Activity that comprises four buttons that each take up a quarter of the screen.
It contains a horizontal LinearLayout that is divided in half by two vertical LinearLayouts as shown in the image below:
http://i.stack.imgur.com/P7Wd3.jpg
Desired Effect:
When I touch a button, I would like it to animate and fill up the entire screen.
Issue:
I have accomplished the animation aspect by changing X and Y scales from 1 to 2 onClick.
The problem is, however, that the animated button will not show when it leaves its parent LinearLayout.
Thoughts
I have tried making the non-animated buttons invisible, but the animated button will only show in its parent LinearLayout.
I know this problem would be solved if I had used a single LinearLayout, but I was unable to use the "layout:weight" feature to make each button take up half of both width and length.
So... How should I approach this issue?
I would appreciate any help :)
Try using a single RelativeLayout. Check this post for a nice example. You may have to setVisibility(View.INVISIBLE) for the other buttons.
Alternative:
Construct a RelativeLayout as above but put that as the only child
of a FrameLayout.
When animating a button, remove it from the RelativeLayout and add it to the FrameLayout specifying the gravity in the LayoutParams appropriately. This way the rest of the buttons will also be seen in the background during the animation.

Categories

Resources