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. Android:滑動抽屜
- 4. 滑動抽屜Android
- 5. 滑動抽屜在VideoView下打開
- 6. 部分打開滑動抽屜
- 7. 禁用打開滑動抽屜
- 8. Android上下滑動抽屜
- 9. 滑動抽屜選項android
- 10. 如何在首頁按鈕上滑動打開滑動抽屜
- 11. Android:在Eclipse中以圖形佈局打開滑動抽屜?
- 12. Android:滑動抽屜式動畫
- 13. 滑動抽屜打開時不活動的背景
- 14. 滑動抽屜動畫
- 15. Android的滑動抽屜不工作
- 16. 在android中滑動抽屜問題
- 17. Android半透明滑動抽屜
- 18. 滑動抽屜下的內容 - Android
- 19. Android導航滑動抽屜TabView
- 20. Android:從頂部滑動抽屜
- 21. 如何添加向右滑動以打開導航抽屜
- 22. 單擊ImageView時如何打開滑動導航抽屜?
- 23. 滑動時打開導航抽屜(Material Design Lite)
- 24. DrawerLayout不是滑動抽屜
- 25. 導航抽屜不滑動
- 26. 滑動抽屜隱藏ListView
- 27. 滑動抽屜不顯示
- 28. 的Android無法打開抽屜內onReceivedError
- 29. Android 5漢堡包不打開抽屜
- 30. 試圖在android中開發一個滑動抽屜類型View?
謝謝你看看,也animateOpen()與動畫開幕。 – fullMoon 2014-12-29 05:26:12