我已经在我的应用程序中使用了一个图标调整了导航抽屉,如图1所示,似乎没问题。 我想在谷歌地图的右侧底部显示图标。
代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
setupSlideMenu();
}
private void setupSlideMenu() {
mPlanetTitles = getResources().getStringArray(R.array.planets_array);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout1);
addIcon();
mDrawerList = (ListView) findViewById(R.id.left_drawer1);
// Set the adapter for the list view
mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPlanetTitles));
// Set the list's click listener
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
log("setupSlideMenu", false);
}
private void addIcon() {
mDrawerToggle = new ActionBarDrawerToggle(
this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description */
R.string.drawer_close /* "close drawer" description */
) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
}
};
// Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Pass the event to ActionBarDrawerToggle, if it returns true, then it has handled the app icon touch event
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle your other action bar items...
return super.onOptionsItemSelected(item);
}
有什么想法吗? 提前谢谢!
答案 0 :(得分:2)
使用BottomDrawerToggle。 解决方案非常简单:
使用重力BOTTOM将<{1}}添加到android.R.id.content FrameLayout
通过将右/左边距设置为其可绘制宽度的一半的负值,使ImageView
一半可见。
已解析的内部资源ImageView
并将其用作图片视图的底部填充
action_bar_icon_vertical_padding
创建了int id = Resources.getSystem().getIdentifier("action_bar_icon_vertical_padding", "dimen", "android");
float padding = mActivity.getResources().getDimension(id);
并计算了当抽屉在SlidingDrawable
方法中滑入/滑出时如何动态隐藏drawable。通过使用抽屉的可见像素量剪切draw(Canvas canvas)
来隐藏Drawable。
Rect