在DrawerLayout形式从右向左滑动ExpandableListView [英] slide ExpandableListView at DrawerLayout form right to left
问题描述
如何在DrawerLayout表格右侧滑动ExpandableListView至左
我想告诉ExpandableListView在屏幕的右上角,我怎么能做到这一点?
< android.support.v4.widget.DrawerLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / drawer_layout
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<的FrameLayout
机器人:ID =@ + ID / content_frame
机器人:layout_width =match_parent
机器人:layout_height =match_parent/>
< ExpandableListView
机器人:ID =@ + ID / left_drawer
机器人:layout_width =240dp
机器人:layout_height =match_parent
机器人:layout_gravity =开始
机器人:choiceMode =singleChoice
机器人:分隔=@机器人:彩色/白
机器人:dividerHeight =0dp
/>
< /android.support.v4.widget.DrawerLayout>
修改安卓layout_gravity =开始
为安卓layout_gravity = 结束
或安卓layout_gravity =正确的
(使用结束
将放抽屉屏幕从右到左的配置)
修改
看来, ActionBarDrawerToggle
正在寻找在同一侧操作栏主页图标抽屉(Gravity.START $ C <$ C C $> $ C>),这将是左侧的左到右的布局方向。如果你将永远有在右边的抽屉里,你可以做这样的事情:
mDrawerToggle =新ActionBarDrawerToggle(这一点,mDrawer,R.drawable.ic_drawer,R.string.open_drawer,R.string.close_drawer){
@覆盖
公共布尔onOptionsItemSelected(菜单项项){
如果(项目= NULL和放大器;!&安培; item.getItemId()== android.R.id.home){
如果(mDrawer.isDrawerOpen(Gravity.RIGHT)){
mDrawer.closeDrawer(Gravity.RIGHT);
} 其他 {
mDrawer.openDrawer(Gravity.RIGHT);
}
}
返回false;
}
};
如果抽屉永远是操作栏主页图标相反,你可以使用 Gravity.END
代替。
How to slide ExpandableListView at DrawerLayout form right to left
i want to show ExpandableListView at right corner of screen , how can i do that ??
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/white"
android:dividerHeight="0dp"
/>
</android.support.v4.widget.DrawerLayout>
Change android:layout_gravity="start"
to either android:layout_gravity="end"
or android:layout_gravity="right"
(using end
will put the drawer on the left side of the screen for right-to-left configurations)
EDIT
It appears that the ActionBarDrawerToggle
is looking for a drawer on the same side as the action bar Home icon (Gravity.START
), which would be the left side for left-to-right layout directions. If you will always have the drawer on the right, you could do something like this:
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, R.drawable.ic_drawer, R.string.open_drawer, R.string.close_drawer) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item != null && item.getItemId() == android.R.id.home) {
if (mDrawer.isDrawerOpen(Gravity.RIGHT)) {
mDrawer.closeDrawer(Gravity.RIGHT);
} else {
mDrawer.openDrawer(Gravity.RIGHT);
}
}
return false;
}
};
If the drawer will always be opposite the action bar Home icon, you could use Gravity.END
instead.
这篇关于在DrawerLayout形式从右向左滑动ExpandableListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!