现在我刚刚在Android Studio中启动了一个项目,其中NavigationBar已在模板中预先配置。显然它将导航抽屉放在操作栏后面。您发现的许多问题都希望导航抽屉位于操作栏的顶部,我希望将其从操作栏下方开始。这就是我目前所拥有的:
最终期望的情况:
我找到了this解决方案,但我认为应该有一种更简单的方法。
答案 0 :(得分:19)
将此属性应用于根视图组android:layout_marginTop="?android:attr/actionBarSize"
。希望这会有所帮助。
答案 1 :(得分:7)
试试这个 MainActivity布局:
public void logoutUser(){
clearSharedPreferences();
Intent broadcastIntent = new Intent();
broadcastIntent.setAction("com.test.your.packgage.ACTION_LOGOUT");
_context.sendBroadcast(broadcastIntent);
// We send a broadcast to all registered activities
// this way all activities will run finish ()
// And they will be automatically closed
LocalBroadcastManager.getInstance(_context).sendBroadcast(broadcastIntent);
}
public void clearSharedPreferences() {
// Clearing all data from Shared Preferences
editor.clear();
editor.commit();
}