2
我正在使用導航抽屜,有12個項目,它運行良好。當我打開導航抽屜時,它是顯示從第三項上我的個人資料圖片頂部是沒有顯示。我想從頂層開始。我的個人資料照片在哪裏?我已經使用了`mDrawerList.setSelection(0);但它是從第三項開始,突然上升。請幫我解決問題。導航抽屜不從頂部位置開始
我的XML代碼如下。
<FrameLayout
android:id="@+id/toolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary_green_header"
android:gravity="center_vertical"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark" />
<!-- The main content view -->
<LinearLayout
android:id="@+id/mainContent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#ffffff"
android:orientation="vertical" />
</LinearLayout>
</FrameLayout>
<ListView
android:id="@+id/nav_list"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@+id/profileBox"
android:layout_gravity="start"
android:background="@color/list_background"
android:choiceMode="singleChoice"
android:divider="@null" />
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
mDrawerList.setSelection(0);
invalidateOptionsMenu();
listAdapter.notifyDataSetChanged();
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
// Log.d(TAG, "onDrawerClosed: " + getTitle());
Log.e("TKB", " Nav Drawer is closed");
mDrawerList.setSelection(0);
//invalidateOptionsMenu();
}
};
你可以顯示你的XML? – keshav
添加我的xml代碼請幫助我@keshav –
請添加您的Java代碼,因爲哪個項目應該是默認的,它只在Java上聲明,這裏使用的是一個很好的例子[LINK](https://github.com/codepath/ android_guides/wiki/Fragment-Navigation-Drawer) – Firefog