Is it possible to make the title sticky in the NavigationView Design Support Library?
<android.support.design.widget.NavigationView
android:id="@+id/nav_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:menu="@menu/nav_drawer"
style="@style/navigation_view_drawer"
/>
EDIT:
My attempts so far have led to this
Overriding the NavigationView widget and adding a new method:
public class CustomNavigationView extends NavigationView {
public CustomNavigationView(Context context) {
super(context);
}
public CustomNavigationView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomNavigationView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void createHeader(int res) {
LayoutInflater inflater = LayoutInflater.from(getContext());;
View view = inflater.inflate(res, this, false);
addView(view);
}
}
Then adding this to the onCreate activity:
CustomNavigationView navigationView = (CustomNavigationView) findViewById(R.id.your_navigation_view);
navigationView.createHeader(R.layout.your_header);
This gives the desired effect (if the bit is cracked), but when the menu items are below the title bar, you can still click them, any ideas to fix this?
source
share