EDIT: solved! Awnser 1. can't push/vote it up
I'm trying to figure out for hours what's the best way to make an "closing credits" activity. Right now I have a TableLayout
inside a RelativeLayout
to center the table.
I am using a simple animation file:
<translate
android:duration="20000"
android:fromYDelta="100%p"
android:toYDelta="-100%p" />
The problem is, the credits table is much bigger than the screen, around 4 times bigger so the table gets cut at screen dimension. Animation works fine, but only the viewable part of the table walks through the display.
Is there a smarter way to create closing credits? Is it possible in android to not cut the table at display dimensions?
Maybe this is too much text anyway? (with ScrollView
I get "View too large to fit into drawing cache")
EDIT: With Luksprog help I got the whole table to scrolldown. Like already mentioned, it's much to fast now. Now I have problems to control the speed via an handler or timertask. because to display and make the table scrollable, i found in the web this solution, otherwise it didn't scroll:
public class Credits extends Activity {
int mesuredHeightScroll;
ScrollView scroll;
boolean first_time = true;
protected void onCreate(Bundle savedInstanceState) {
if (first_time == true) {
super.onCreate(savedInstanceState);
setContentView(R.layout.credits);
scrolldownthetable();
}
}
private void scrolldownthetable() {
// TODO Auto-generated method stub
final ScrollView scroll = (ScrollView) findViewById(R.id.scrolltable);
TableLayout table = (TableLayout) findViewById(R.id.table);
OnGlobalLayoutListener listener = new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
scroll.smoothScrollTo(0, mesuredHeightTable);
}
};
table.getViewTreeObserver().addOnGlobalLayoutListener(listener);
};
/**
* Draw the Layout, otherwise getMesuredHeight returns 0, null onCreate
* to call it again, first time to false, so onCreate doesn't call again on
* focus change (resume,pause...)
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
ScrollView scroll = (ScrollView) findViewById(R.id.scrolltable);
TableLayout table = (TableLayout) findViewById(R.id.table);
mesuredHeightTable = table.getMeasuredHeight();
mesuredHeightScroll = scroll.getMeasuredHeight();
onCreate(null);
first_time = false;
}
}
Is there anyway to get this scrollTo() automated inside the Globallayoutlistener? Or is my code stupid and theres a more comfortable way? It would be great if someone could help me with some code, because i am running out of time :/
Is there a smarter way to create closing credits? Is it possible android not to cut the table at displydimensions?
As your table is most likely enclosed in a ScrollView
you could add another view at the bottom that is as big as the screen and then use the smoothScrollTo()
on the ScrollView
itself.
As you probably want more control over the animation, especially the speed, I think you could use a Handler
or CountDownTimer
to simply call scrollTo()
on the ScrollView
at short time intervals.