我正在尝试设置我的应用程序的自定义视图,但我所做的布局没有填充整个操作栏。
我尝试了很多样式设置,但没有一个对我有用。
这是我在活动中的代码
View view = getLayoutInflater().inflate(R.layout.actionbar_customized_home, null);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(view);
这是设置为视图的布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/actionbar_color"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerInParent="true"
android:scaleType="fitCenter"
android:src="@drawable/logo"/>
</RelativeLayout>
即使是导航抽屉等菜单项的背景,如何将自定义视图设置为背景颜色?
我真的很感谢你的帮助
这就是您需要添加的全部内容onCreate()
getSupportActionBar().setCustomView(new CustomView(this));
getSupportActionBar().setDisplayShowCustomEnabled(true);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)