2012-04-23 44 views
0

當我使用滑動抽屜時,我希望佈局消失,以便滑動抽屜不會被阻擋。使佈局不見

但是,我嘗試過很多辦法,如

view = (View)findViewById(R.id.layout_latestcontent); 
    view.setVisibility(View.GONE); 

linear = (LinearLayout)findViewById(R.id.layout_latestcontent); 
    linear.setVisibility(2); 

雙方還不能。

public void onDrawerClosed() { 
    //view = (View)findViewById(R.id.layout_latestcontent); 
    //view.setVisibility(View.VISIBLE); 
} 

public void onDrawerOpened() { 
    //view = (View)findViewById(R.id.layout_latestcontent); 
    //view.setVisibility(View.GONE); 
} 

即使是同時實現的功能也不能

如何使整個佈局到哪裏去了?

回答

0

您只能在android:visibility視圖的屬性中應用值2(或任何this)。如果你想從代碼中改變視圖可見性,你應該使用常量View.VISIBLE,View.INVISIBLE或View.GONE(常量值爲0,4,8)。 linear.setVisibility(View.GONE)而不是linear.setVisibility(2)

+0

public void onDrawerOpened()and onDrawerClosed()好像不能進去。當我打開抽屜時,它不會消失 – 2012-04-23 08:27:02