2012-02-10 53 views
0

如何在其他片段被隱藏時調整片段大小?換句話說,當我刪除或隱藏片段「A」(或listFragment)時,該空間是空的。我需要剩餘的片段「B」來調整大小並填充片段「A」所在的空間,使片段「B」佔據整個屏幕。任何幫助代碼示例將不勝感激。 Thnx片段大小如何?

回答

0
android.support.v4.app.Fragment frag = getSupportFragmentManager().findFragmentById(R.id.page_list); 
android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 

    if(this.isVisible){ 
     this.isVisible=false; 
     ft.hide(frag); 
    }else{ 
     this.isVisible=true; 
     ft.show(frag); 
    } 
    ft.commit(); 

此代碼將用R.id.page_list ID隱藏ListFragment,另一個(content)將自動調整其自身大小。