我的SlidingDrawer测试反应错误,我开发的是为了从左到右工作,但它从右到左工作。
谁能告诉我我做错了什么?
我的布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<SlidingDrawer
android:id="@+id/slidingDrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="left"
android:allowSingleTap="true"
android:handle="@+id/handle"
android:content="@+id/content">
<ImageView
android:contentDescription="content"
android:id="@id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_sliding_to_right"/>
<ImageView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/android_robot" />
</SlidingDrawer>
</RelativeLayout>
我的活动
package com.pack.myslidingdrawer;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SlidingDrawer;
import android.widget.SlidingDrawer.OnDrawerCloseListener;
import android.widget.SlidingDrawer.OnDrawerOpenListener;
import android.widget.SlidingDrawer.OnDrawerScrollListener;
import android.widget.TextView;
public class MainActivity extends Activity {
SlidingDrawer drawer;
ImageView handle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawer = (SlidingDrawer)findViewById(R.id.slidingDrawer);
handle = (ImageView)findViewById(R.id.handle);
drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
// Set another direction Icon
ImageView view=(ImageView)drawer.getHandle();
view.setImageResource(R.drawable.ic_action_sliding_to_left);
}
});
drawer.setOnDrawerCloseListener(new OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
// Set another direction Icon
ImageView view=(ImageView)drawer.getHandle();
view.setImageResource(R.drawable.ic_action_sliding_to_right);
}
});
}
}
所以我理解SlidingDrawer android:orientation="horizontal"
和android:gravity="left"
确定水平方向以及handle
应该在哪里,我错了吗?
我事先感谢你的帮助。