【问题标题】:How to make Toolbar transparent and put an image backwards it?如何使工具栏透明并将图像向后放置?
【发布时间】:2015-11-25 23:39:29
【问题描述】:

我希望ToolBar 是透明的。我有一个显示工具栏的活动,如下所示:

我的 xml 中有这个:

 <android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:elevation="0dp"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/transparent" />

</android.support.design.widget.AppBarLayout>

但我不能让我的 Activity 位于顶部并在我的工具栏后面可见...

我怎样才能做到这一点?

【问题讨论】:

  • Toolbar制作布局文件并在其中添加ImageView
  • 我所有的活动都来自这个工具栏,所以我不认为这是一个解决方案......

标签: android


【解决方案1】:

StackOverflow 不允许我发表评论,因为我没有 50 名声望,这就是我在答案框中发表评论的原因

你可以在这里找到你的答案:

How to make the support Toolbar background transparent?

How to make Toolbar transparent?

【讨论】:

  • 想做同样的事情。
  • 那么我的问题是我的活动由于某种原因被向下移动了......为什么它看起来向下?=
【解决方案2】:

@RAP 的回答似乎有效。但请注意,如果您将背景设置为透明,则意味着当用户触摸工具栏并执行一些您不想要的操作时,工具栏仍然是可点击的。实现目标的其他替代方法是将其可见性设置为INVISIBLE

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

toolbar.setVisibility(View.INVISIBLE);

// to make it appear again:
toolbar.setVisibility(View.VISIBLE);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-12
    • 1970-01-01
    • 2020-03-04
    • 1970-01-01
    相关资源
    最近更新 更多