简体   繁体   English

在应用程序工具栏中添加图标(徽标)-空活动

[英]Add icon(logo) in app toolbar - empty activity

I used these lines of code in Java: 我在Java中使用了以下几行代码:

getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.logo);

But my logo looks like this: 但是我的徽标看起来像这样:

LOGO: 商标:

在此处输入图片说明

How can I set width of this logo or so it actually looks like a logo? 如何设置此徽标的宽度,或者使其实际上看起来像徽标? :) :)

You can add image in toolbar and arrange in the center accordingly. 您可以在工具栏中添加图像,并相应地排列在中间。

<android.support.v7.widget.Toolbar
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:background="?attr/colorPrimary">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/logo"/>

 </android.support.v7.widget.Toolbar>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM