🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / Android RMOS / action bar menü iconun yanına veya altına yazı ekleme

1-) Android RMOS - action bar menü iconun yanına veya altına yazı ekleme

 

kaynak : https://stackoverflow.com/questions/36199215/how-to-show-text-below-icon-in-toolbar-menu/37319165

 

 

menu_nfc.xml

 

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    
xmlns:app="http://schemas.android.com/apk/res-auto">
    <
item
        
android:id="@+id/menuNfcBarkod"
        
android:icon="@drawable/barkod_beyaz"
        
android:orderInCategory="0"
        
android:title="QR - Barcode"
        
app:showAsAction="always"
        
android:actionLayout="@layout/nfc_menu" />
</
menu>

 

 

nfc_menu.xml

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    
android:layout_width="match_parent"
    
android:layout_height="match_parent"
    
android:gravity="center"
    
android:orientation="horizontal"
    
>
    <
ImageView
        
android:layout_width="wrap_content"
        
android:layout_height="wrap_content"
        
android:src="@drawable/barkod_beyaz"
        
android:layout_marginRight="5dp"
        
/>

    <
TextView
        
android:layout_width="match_parent"
        
android:layout_height="wrap_content"
        
android:gravity="center"
        
android:paddingLeft="0dp"
        
android:text="BARKOD OKU"
        
android:textColor="@color/colorWhite"
        
android:textSize="12dp"
        
android:layout_marginRight="5dp"

        
/>
</
LinearLayout>

 

CLİCK EVENTİNİ BU ŞEKİLDE AYARLAMAK GEREKİYOR ARTIK

 

Menu menu;
MenuInflater
inflater;

@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
    
this.menu = menu;
    
this.inflater = inflater;
    menu.clear();
    inflater.inflate(R.menu.
menu_nfc, menu);

    View your_menu_view = menu.findItem(R.id.
menuNfcBarkod).getActionView();
    your_menu_view.setOnClickListener(
new View.OnClickListener() {
        
@Override public void onClick(View v) {
            Toast.
makeText(getContext(), "Barkodd Açılıyor...", Toast.LENGTH_SHORT).show();
        } });   
}

 2021 Aralık 09 Perşembe
 421