You could add an icon to the toolbar in the Android app project.
The default layout for the toolbar in a new template Forms app is:
<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" >
</android.support.v7.widget.Toolbar>
Add an icon to 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="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<ImageView
android:src="@drawable/star_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.Toolbar>
Updated:
Set id for the imageview in Toolbar.
<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:id="@+id/imageView1"
android:src="@drawable/star_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.Toolbar>
Add the code in MainActivity after LoadApplication(new App());
.
var imageview = FindViewById<ImageView>(Resource.Id.imageView1);
imageview.Click += delegate
{
Console.WriteLine("start clicked!");
};
How can I enter HorizontalOptions="End" in the Toolbaritem.xml? I want to go to the right side of the page!
Add the code below in ImageView.
android:layout_gravity="end"
Screenshot:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…