android - 如何制作结束学分页面 - 动画 TableLayout 而不会在显示尺寸处被切割

标签 android android-layout animation android-tablelayout credits

编辑: 解决了! Awnser 1. 无法推送/投票

我花了好几个小时想弄清楚什么是进行“结束演职员表” Activity 的最佳方式。现在我在 RelativeLayout 中有一个 TableLayout 来使表格居中。 我正在使用一个简单的动画文件:

<translate
android:duration="20000" 
android:fromYDelta="100%p"
android:toYDelta="-100%p" /> 

问题是,演职员表比屏幕大得多,大约是屏幕的 4 倍 所以 table 在屏幕尺寸上被切割。动画效果很好,但只有表格的可见部分在显示中移动。

有没有更聪明的方法来创建结束学分?在 android 中是否可以不按显示尺寸切割表格?

也许文字太多了? (使用 ScrollView 我得到“View too large to fit into drawing cache”)

编辑: 在 Luksprog 的帮助下,我让整个表格向下滚动。就像已经提到的,现在要禁食很多。现在我无法通过处理程序或定时器任务来控制速度。因为要显示和使表格可滚动,我在网上找到了这个解决方案,否则它没有滚动:

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

有没有办法在 Globallayoutlistener 中使这个 scrollTo() 自动化? 还是我的代码很愚蠢并且有更舒适的方法? 如果有人可以帮助我编写一些代码,那就太好了,因为我的时间不多了:/

最佳答案

Is there a smarter way to create closing credits? Is it possible android not to cut the table at displydimensions?

由于您的表格很可能包含在 ScrollView 中,您可以在底部添加另一个与屏幕一样大的 View ,然后使用 smoothScrollTo()ScrollView 本身上。

由于您可能想要更多地控制动画,尤其是速度,我认为您可以使用 HandlerCountDownTimer 来简单地调用 scrollTo() 以较短的时间间隔显示在 ScrollView 上。

关于android - 如何制作结束学分页面 - 动画 TableLayout 而不会在显示尺寸处被切割,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17260073/

相关文章:

Android 布局无法正常工作

android - 无法单击 CollapsingToolbarLayout 中的项目

java - 绕圈移动物体 - android

ios - 停止调用 -removeAllAnimaitions

java - 无法从android接收php中的post参数?

android - 如何在 android Kiosk 模式应用程序中访问相机或图库?

java - 安卓应用程序 : Cannot pass method from another class into the main class

java - 即使我提供了错误的密码并且文件未保存在服务器上,我总是得到服务器响应 ok 200

android - 呈现问题 :Binary XML file line #-1: No start tag found

ios - 自定义 UIViewController 转换不会执行下一个动画