c# - How do I create hamburger panels/side drawers with Xamarin.Android? (5.0+) -
i'm targetting android version 5.0 minimal set 4.4. i'd create simple side menu users can select option/page of app.
the problem i'm facing number of recommended solutions on various blogs, forums , documentation pages. many of them require downloading various component , additional libraries, support libraries backwards compatibility.
what method can use if don't need backwards compatibility , want make android application ugly new material design in mind?
are there built-in components that? or downloading these libraries , doing ton of setup them best option have?
are there built-in components that? or downloading these libraries , doing ton of setup them best option have?
the navigationview drawerlayout
official recommended way achieve slidable hamburger panel. said, use it, material design(android support design library) need installed.
if don't want use it. there way implement side drawer directly using fragment
. example:
in activity's layout:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:id="@+id/sidedrawer" android:orientation="vertical" android:layout_height="match_parent" android:layout_width="wrap_content" android:background="@drawable/drawerborder"> <button android:id="@+id/home" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="home" /> <button android:id="@+id/settings" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="settings" /> </linearlayout> <framelayout android:id="@+id/container" android:layout_height="match_parent" android:layout_width="wrap_content" /> </linearlayout>
code behind:
protected override void oncreate(bundle savedinstancestate) { base.oncreate(savedinstancestate); // create application here setcontentview(resource.layout.layout1); button home = findviewbyid<button>(resource.id.home); home.click += (sender, e) => { fragmenttransaction transaction = this.fragmentmanager.begintransaction(); homefragment homefragment = new homefragment(); transaction.replace(resource.id.container, homefragment).commit(); }; button settings = findviewbyid<button>(resource.id.settings); settings.click += (sender, e) => { fragmenttransaction transaction = this.fragmentmanager.begintransaction(); settingsfragment settingsfragment = new settingsfragment(); transaction.replace(resource.id.container, settingsfragment).commit(); }; }
i didn't add gesture , animation sidedrawer
make slidable. can try yourself.
but can't tell way easier, in opinion, installing packages more convenient. use method mentioned above, many works need done our self. example, slide-in/ slide-out animation, gesture recognition, border of drawer. yes, think downloading these libraries best option.
edit: forgot say, if want pop side drawer, may try use custom dialog.
Comments
Post a Comment