[英]Navigation Drawer not Starting from top position
我正在使用導航抽屜,有12個項目,並且運行良好。當我打開導航抽屜時,這是第三個項目的頂部,我的個人資料圖片位於頂部,沒有顯示。 我想從頭開始。 我的個人資料照片在哪里。 我已經使用了`mDrawerList.setSelection(0); 但是它從第3個項開始,突然達到頂峰。 請幫助我解決問題。
我的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();
}
};
您可以使用smoothScroll選擇導航抽屜的索引。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.