Android Programlama -21

Merhaba arkadaşlar bu gün ki makalemde BottomNavigationView’ ın kullanımını göreceğiz.

Bir önceki makalede fragment konusuna değinmiştim. Okumadıysanız öncelikle onu okumanızı tavsiye ederim. Buradan okuyabilirsiniz.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.teka.icim_rahat.Icim_Rahat">

    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

    </FrameLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_gravity="bottom"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />

</LinearLayout>

Yazdığımız xml kodlamasının çıktısının ekran görüntüsü yukarıdaki gibi dir. Ekran görüntüsündeki telefonun alt kısmında bulunan butonlar ButtomNavigationView sayesinde eklenmiştir uygulamaya. Ekranın en alt kısmın da bulunan butunlar’a tıklandığın da farklı sayfalar açılmaktadır. Bu sayfalarda fragment ile kodlanmış sayfalardır. BottomNavigationView’i dogru kullanabilmemiz için framelayout kullanmalıyız xml kodlamamız da.

Burada önemli bir noktada BottomNavigationView da kaç tane sayfa olacağını belirlediğimiz kısımdır. Bunu bir menu dosyası oluşturarak app:menu=”@menu/navigation” xml kodlaması yardımı ile belirlemiş oluruz.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/ic_home_black_24dp"
        android:title="Fotograf" />

    <item
        android:id="@+id/navigation_dashboard"
        android:icon="@drawable/ic_group_black_24dp"
        android:title="Ögretmen" />

    <item
        android:id="@+id/navigation_notifications"
        android:icon="@drawable/ic_sentiment_satisfied_black_24dp"
        android:title="Ögrenci" />
    <item
        android:id="@+id/iletisim"
        android:icon="@drawable/ic_assignment_black_24dp"
        android:title="Hakkımızda">


    </item>
</menu>

Uygulamamız da kullandığımız menu kodları yukarıdaki gibidir. Her buton’u bir item temsil etmektedir. Her item’ın da id, icon ve tittle bilgileri mevcuttur.

Bir makalenin daha sonuna geldik, esenle kalın..

 167 views last month,  1 views today

About Kübra Hebeş

Bilgisayar Mühendisi

Check Also

Android Programming -12 ArrayAdapter

Hı guys in this tutorial  We will see the use of arrayadapters in android programming. …

9 comments

  1. I do agree with all the concepts you’ve presented on your post. They’re very convincing and can definitely work. Still, the posts are too short for beginners. May you please extend them a bit from next time? Thank you for the post.|

  2. Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how can we communicate?|

  3. This piece of writing is really a pleasant one it assists new internet users, who are wishing in favor of blogging.|

  4. I loved as much as you will receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get got an shakiness over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.|

  5. I am not sure where you are getting your info, but good topic. I needs to spend some time learning more or understanding more. Thanks for wonderful info I was looking for this information for my mission.|

  6. Magnificent beat ! I wish to apprentice while you amend your web site, how could i subscribe for a blog website? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear idea|

  7. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your weblog? My blog is in the exact same area of interest as yours and my visitors would truly benefit from a lot of the information you present here. Please let me know if this alright with you. Many thanks!|

  8. Hello mates, pleasant piece of writing and nice arguments commented at this place, I am genuinely enjoying by these.|

Leave a Reply