1
A
回答
4
XML佈局 - 在一個基本的LinearLayout:
<SlidingDrawer
android:id="@+id/slide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="vertical"
android:scrollbars="vertical" >
<LinearLayout
android:id="@id/handle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/btn"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/handleImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_tray_expand" />
<Button
android:id="@+id/handleButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/btn"
android:text="Up me" />
</LinearLayout>
<LinearLayout
android:id="@+id/content"
android:paddingTop="2dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#013E53"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_commentDisplay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="10dp"
android:textSize="20dp" />
</LinearLayout>
</SlidingDrawer>
而且你的活動將是這樣的:
public class Home extends Activity implements OnDrawerScrollListener
{
private ImageView handleImage;
private Button handleButton;
private SlidingDrawer slide;
private TextView tv_commentDisplay;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
tv_commentDisplay = (TextView)this.findViewById(R.id.tv_commentDisplay);
handleImage = (ImageView)this.findViewById(R.id.handleImage);
handleButton = (Button)this.findViewById(R.id.handleButton);
slide = (SlidingDrawer)this.findViewById(R.id.slide);
slide.open(); // not sure
slide.setOnDrawerScrollListener(this);
handleButton = ((Button)this.findViewById(R.id.handleButton));
tv_commentDisplay.setText("Hello World");
}
@Override
public void onScrollEnded() {
}
@Override
public void onScrollStarted() {
if (slide.isOpened())
handleImage.setImageResource(R.drawable.ic_tray_collapse);
else {
handleImage.setImageResource(R.drawable.ic_tray_expand);
}
}
1
使用open()
在onCreate()
,它會打開抽屜立即。
您可以在完整的API here
相關問題
- 1. 滑動抽屜Android不打開
- 2. Android:滑動抽屜
- 3. 部分打開滑動抽屜
- 4. Android上下滑動抽屜
- 5. 如何在首頁按鈕上滑動打開滑動抽屜
- 6. Android:在Eclipse中以圖形佈局打開滑動抽屜?
- 7. 滑動抽屜打開時不活動的背景
- 8. Android導航滑動抽屜TabView
- 9. 在android中滑動抽屜問題
- 10. 滑動抽屜下的內容 - Android
- 11. Android:從頂部滑動抽屜
- 12. 如何添加向右滑動以打開導航抽屜
- 13. 滑動時打開導航抽屜(Material Design Lite)
- 14. 單擊ImageView時如何打開滑動導航抽屜?
- 15. DrawerLayout不是滑動抽屜
- 16. 滑動抽屜隱藏ListView
- 17. Android 5漢堡包不打開抽屜
- 18. 的Android無法打開抽屜內onReceivedError
- 19. 項目導航抽屜打開活動
- 20. 隱藏Notifaction抽屜打開時活動
- 21. 如何在代碼中創建滑動抽屜?
- 22. 帶抽屜的Android抽屜
- 23. 黑莓手機 - 如何創建一個像滑動抽屜的佈局android
- 24. 滑動抽屜窗簾動畫
- 25. 如何阻止Android抽屜自動打開?
- 26. Android導航抽屜不能滑出
- 27. MMDrawerController - 從中心抽屜中的按鈕打開左抽屜
- 28. 創建telerik側抽屜
- 29. 創建導航抽屜
- 30. 材料抽屜在活動開始時自動打開
謝謝你看看,也animateOpen()與動畫開幕。 – fullMoon 2014-12-29 05:26:12