XML形状背景颜色未呈现

时间:2019-03-11 08:30:10

标签: android android-layout android-drawable android-shape

我已经定义了一个包含两个项目的可绘制XML文件。这是代码

首先这是MainActivity布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/relLayout1">
        <include layout="@layout/layout_top_tabs"/>
    </RelativeLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/relLayout2"
        android:layout_below="@id/relLayout1"
        android:background="@color/white">
        <include layout="@layout/layout_center_viewpager"/>

    </RelativeLayout>

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

</RelativeLayout>

在layout_bottom_navigation中,我使用了BottomNavigationEX

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">


<RelativeLayout

    android:layout_width ="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true">

  <com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/bottomNavViewBar"
    android:background="@drawable/white_grey_border_top"
    app:menu="@menu/bottom_navigation_menu">

</com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx>

</RelativeLayout>
</merge>

然后我在bottom_Navigation_menu中定义了这样的MenuItems

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:id="@+id/ic_house"
    android:icon="@drawable/ring_cicle_home"
    android:title="">
</item>


<item
    android:id="@+id/ic_search"
    android:icon="@drawable/ring_cicle_search"
    android:title="">
</item>

<item
    android:id="@+id/ic_circle"
    android:icon="@drawable/ic_circle"
    android:title="">
</item>

<item
    android:id="@+id/ic_alert"
    android:icon="@drawable/ic_alert"
    android:title="">
</item>

<item
    android:id="@+id/ic_android"
    android:icon="@drawable/ic_android"
    android:title="">
</item>
</menu>

这是ring_circle_search

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:innerRadius="25dp"
        android:shape="ring"
        android:thickness="5dp"
        android:useLevel="false">
        <solid android:color="@color/off_red" />

        <padding
            android:left="11dp"
            android:right="11dp"/>
    </shape>

</item>
<item
    android:drawable="@drawable/ic_search"
    android:width="40dp"
    android:height="50dp"/>
</layer-list>

预览显示如下:

enter image description here

但红色背景未在android设备中呈现。而是变成了蓝色的原色。

任何人都可以指出是什么问题吗?

0 个答案:

没有答案