Icons in Navigation Toolbar with PageTitle

DanielSchmittDanielSchmitt Member ✭✭
edited July 2018 in Xamarin.Forms

I read the article of @JamesMontemagno - "Xamarin.Forms - Icons in Navigation Toolbar" and im asking myself if it is possible to have that application-wide image in the NavigationBar in combination with the PageTitle. Because adding an ImageView to the Toolbar.axml like this will hide the PageTitle.

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:popupTheme="@style/ThemeOverlay.AppCompat.Light">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:scaleType="fitCenter"
        android:src="@drawable/xamarin_logo"
        android:layout_gravity="center" />
</android.support.v7.widget.Toolbar>

Does anyone successfully tried having an application-wide Image in combination with the PageTitle?

Best Answer

Answers

  • sumeyyaararsumeyyaarar USMember ✭✭
    edited July 2018

    You can give toolbar a background image like this:

    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/background_image"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
    

    and set Title in your page. This should do what you want.

  • DanielSchmittDanielSchmitt Member ✭✭

    @sumeyyaarar, thanks for your answer.

    I guess thats a nice workaround solution, but what if you deploy your app to a smartphone / tablet / pc with another aspect ratio or turn it in landscape mode? I think the BackgroundImage will be croped or fitted depending on the layout settings, isn't it? This wouldn't look good in a company logo.

    Are there any other Solutions?

Sign In or Register to comment.