首先我知道这个问题在这里出现过,但想了很多,我仍然没有成功之后。 我正在从示例 Android开发者网站。
First of all I know this question appeared here before but after trying a lot i still didn't succeed. I working on the example from Android Developers site.
我试图将菜单设置为从右开到左其在本例中是如何实现(从左至右)代替。此外,我希望移动的开放式菜单按钮,右边的行动吧。我也红了一些答案,例如:in这个答案。
I'm trying to set the menu to be opened from right to left instead of how its implementing in the example (from left to right). In addition I want to move the open menu button to the right side of the action bar. I also red some answers here, for example in this answer.
我试图改变的意见和布局的重心,但是我得到的错误:
I try to change the gravity of the views and the layouts but I get the error:
没有与绝对重力LEFT发现抽屉里查看
您可以请帮我弄清楚什么是我的code和我应该以设置菜单中更改从右侧打开,移动操作栏按钮右侧的问题?
Can you please help me to figure out what is the problem in my code and what should I change in order to set the menu to be opened from the right, and to move the action bar button to the right side?
在XML code是在这里:
the xml code is here:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_gravity="right"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ListView android:id="@+id/left_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
谢谢大家。
推荐答案
在主布局设置你的ListView重心向右:
In your main layout set your ListView gravity to right:
android:layout_gravity="right"
另外,在您的code:
Also in your code :
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, R.string.drawer_open,
R.string.drawer_close) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item != null && item.getItemId() == android.R.id.home) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
mDrawerLayout.closeDrawer(Gravity.RIGHT);
} else {
mDrawerLayout.openDrawer(Gravity.RIGHT);
}
}
return false;
}
};
希望工程:)
hope it works :)
相关推荐
最新文章