【问题标题】:Add icons left of toolbar Android (xamarin)在工具栏左侧添加图标 Android (xamarin)
【发布时间】:2015-07-18 11:31:05
【问题描述】:

我为新的 v7 工具栏下载了一个示例。我可以在右侧添加自定义图标,但我不知道如何将其添加到左侧。(s 请查看此图片以了解其当前的外观http://postimg.org/image/qnf67g4tz/ 我正在使用的代码在这里。

<?xml version="1.0" encoding="utf-8" ?> 
    <menu xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:local="http://schemas.android.com/apk/res-auto">
       <item
          android:id="@+id/menu_share"
          android:icon="@drawable/ic_action_content_create"
          android:background="@android:color/holo_blue_light"
          local:showAsAction="ifRoom"
          android:title="Share" />
    </menu>

并且: LayoutInflater inflater = (LayoutInflater)Maincontext.GetSystemService (Context.LayoutInflaterService); 查看 v = inflater.Inflate (Resource.Layout.toolbar,null); 工具栏工具栏 = v.FindViewById (Resource.Id.toolbar); 工具栏.Title = 标题; 工具栏.SetTitleTextColor (Color.White); 工具栏.InflateMenu (Resource.Menu.home);

【问题讨论】:

    标签: android xamarin


    【解决方案1】:

    返回箭头图标的xml代码

    <android.support.v7.widget.Toolbar
                android:id="@+id/product_toolBar_title"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="pin"
                app:navigationIcon="@drawable/ic_arrow_back_white_24dp"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
    

    【讨论】:

    • 我收到这个错误 system.xml.xmlexception: 'app' is an undeclared prefix
    • 把它放在你的开始布局标签上 xmlns:app="schemas.android.com/apk/res-auto"
    • 它工作了我不再收到错误但它没有在左侧显示任何内容。我的目标是在 google play store 工具栏上创建类似的东西。我不需要搜索部分,但左边的图标是我想要的
    猜你喜欢
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 2020-05-24
    • 1970-01-01
    • 2018-11-26
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多