【问题标题】:Using the new Toolbar of Android the icons are cut off使用Android的新工具栏图标被切断
【发布时间】:2014-12-28 08:10:41
【问题描述】:

使用 Android 5 的新工具栏,图标似乎被截断了! 我正在使用抽屉式导航和新工具栏。有什么建议吗?

它似乎在工具栏的上方

<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="30dp"
  android:background="?attr/colorPrimary">
 </android.support.v7.widget.Toolbar>

这里是抽屉布局

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <include layout="@layout/toolbar"/>

    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
    </LinearLayout>



    <!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
        android:fitsSystemWindows="true"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@color/gray_light_divider_list_drawerNav"
        android:dividerHeight="1dp"
        android:background="@color/gray_light_background_list_drawerNav"
        />

编辑:在工具栏中添加这两个属性 android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize"

看起来太大了

【问题讨论】:

    标签: android android-5.0-lollipop


    【解决方案1】:

    我在抽屉导航和片段本身中添加了两次工具栏

    【讨论】:

      【解决方案2】:

      工具栏的高度太小了。你的工具栏的 minHeght 应该是这样的

      android:minHeight="?attr/actionBarSize"
      

      【讨论】:

      • 添加上述属性,并且使用 height="wrap_content" 工具栏看起来太大了
      • 这是推荐的工具栏高度。您会看到当您不放置推荐的高度时会发生什么
      • 不,这不是正常高度,您的布局有问题
      【解决方案3】:

      Toolbar 的正常高度是 56dp。尝试将高度设置为该值,它应该看起来正常。

      【讨论】:

      • 看起来一样:S太大了
      • 我找到了它,我在抽屉导航和片段内容中包含了两次工具栏。感谢 cmets
      • 很高兴你知道了!您应该将您的发现作为答案发布,以便其他人在遇到相同问题时可以解决这个问题。
      • 是的,我今天就去做
      猜你喜欢
      • 2015-10-17
      • 2020-04-20
      • 2013-09-04
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-28
      • 2018-01-01
      相关资源
      最近更新 更多