1

編輯: 解決了! Awnser 1.不能推/投它如何使閉幕信用頁 - 在顯示尺寸下無需剪切動畫的TableLayout

我想弄清楚幾個小時什麼是做「閉幕式信用」活動的最佳方式。現在我在RelativeLayout的內部有一個TableLayout來居中表格。 我使用一個簡單的動畫文件:

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

的問題是,學分表比屏幕更大,大約4倍大 所以表被削減的屏幕尺寸。動畫工作正常,但只有表格的可見部分遍歷顯示。

是否有更智能的方法來創建結算信用?在android中可以不顯示尺寸切割表嗎?

也許這是太多的文字呢? (與ScrollView我得到「查看太大,以適應繪圖緩存」)

編輯: 隨着Luksprog的幫助,我得到了整個表scrolldown。就像已經提到的那樣,現在速度很快。現在我遇到了一些問題,通過處理程序或時間任務來控制速度。由於顯示和使表滾動,我在網絡這個解決方案中發現,否則就沒有滾動:

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

}

反正有沒有得到這個scrollTo()的Globallayoutlistener內全自動的嗎? 或者是我的代碼愚蠢和theres更舒適的方式? 這將是巨大的,如果有人可以幫助我的一些代碼,因爲我的時間不多了:/

回答

1

有用來創建片尾一個更聰明的方式?是否有可能 android不會在displydimensions上切表?

當你的表是最有可能封閉在一個ScrollView,你可以在這一樣大屏幕底部添加另外的看法,然後使用上ScrollView本身smoothScrollTo()

正如你可能希望在動畫更多的控制,尤其是速度,我想你可以使用一個HandlerCountDownTimer簡單地呼籲ScrollViewscrollTo()在很短的時間間隔。

+0

當我設置scroll.smoothScrollTo(int,int); x和y整數應該是什麼樣的?當我在屏幕底部添加一個視圖時,就足夠了,導致我的桌子比屏幕大4倍。 thx – eyjin

+0

@eyjin'x'將爲0,'y'爲'ScrollView'中所有視圖高度的總和('view.getMeasuredHeight()'),不包含最後添加的空視圖。 – Luksprog

+0

嘿Luksprog,也許你可以幫我用我貼的新代碼?謝謝你到目前爲止 – eyjin