Reputation: 59
Hello I am beginning Android and i am having this problem. When I run my application on API 23 this cardview is showing like this
It should be showing like this
I am having the same problem on Android 5.0
here is the code of the cardview
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="120dp"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/textsearch"
android:text="filtro"
android:id="@+id/filtro"
android:layout_marginBottom="5dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/boton_cerrar"
android:src="@drawable/ic_close_box"
android:layout_alignParentTop="true"
android:background="@null"
android:layout_alignParentRight="true"/>
<Spinner android:text="@string/opcion"
android:id="@+id/spinner"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:minHeight="50dp"
android:layout_below="@id/filtro"
android:layout_marginRight="5dp"
/>
<EditText
android:id="@+id/texto"
android:layout_width="100dp"
android:gravity="end"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_height="wrap_content"
android:layout_below="@id/spinner"
android:layout_marginEnd="10dp"
android:layout_alignTop="@id/spinner"
android:layout_toRightOf="@id/spinner"
android:layout_marginRight="10dp"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
theme-values.xml ---------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="theme_primary">#3F51B5</color>
<color name="theme_primary_dark">#303F9F</color>
<color name="theme_primary_medium">#7986CB</color>
<color name="theme_accent">#FFC107</color>
<color name="theme_secondary">#795548</color>
<color name="theme_secondary_dark">#5D4037</color>
<color name="colorPrimary">@color/theme_primary</color>
<color name="colorPrimaryDark">@color/theme_primary_dark</color>
<color name="colorAccent">@color/theme_accent</color>
<!-- Drawer Properties -->
<dimen name="drawerAvatarWidthHeight">80dp</dimen>
<!-- Dimensions -->
<dimen name="statusBarHeight">0dp</dimen>
<!-- Booleans -->
</resources>
theme-values.xml (v19) ---------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="theme_primary">#3F51B5</color>
<color name="theme_primary_dark">#303F9F</color>
<color name="theme_primary_medium">#7986CB</color>
<color name="theme_accent">#FFC107</color>
<color name="theme_secondary">#795548</color>
<color name="theme_secondary_dark">#5D4037</color>
<color name="colorPrimary">@color/theme_primary</color>
<color name="colorPrimaryDark">@color/theme_primary_dark</color>
<color name="colorAccent">@color/theme_accent</color>
<!-- Drawer Properties -->
<dimen name="drawerAvatarWidthHeight">80dp</dimen>
<!-- Dimensions -->
<dimen name="statusBarHeight">0dp</dimen>
<!-- Booleans -->
</resources>
theme-values.xml (v21) ---------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Drawer Properties -->
<dimen name="statusBarHeight">24dp</dimen>
<!-- Booleans -->
</resources>
styles.xml
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="AppBar.Dark" parent="ThemeOverlay.AppCompat.Dark.ActionBar"></style>
<!-- FIXME: Replace toolbar with appbar.. -->
<style name="ToolBarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="homeAsUpIndicator">@drawable/ic_action_navigation_menu</item>
<item name="android:homeAsUpIndicator">@drawable/ic_action_navigation_menu</item>
</style>
<style name="ViewSeparator">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">#cccccc</item>
</style>
<style name="cardview_text">
<item name="android:typeface">normal</item>
<item name="android:textColor">@color/color_cardview_text</item>
<item name="android:textSize">20dp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="cardview_header">
<item name="android:typeface">normal</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
<item name="android:textSize">25dp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="textsearch">
<item name="android:typeface">normal</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
<item name="android:textSize">20dp</item>
<item name="android:textStyle">bold</item>
</style>
styles.xml (v19)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
styles.xml (v21)
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
Upvotes: 2
Views: 775
Reputation: 11
Try changing the layout to Linear layout and also checkout this URL.. it looks similar to this..
How do you anchor a Dropdown spinner to a parent Linearlayout?
Upvotes: 0
Reputation: 505
change background color of cardview:
card_view:cardBackgroundColor="@android:color/white"
Upvotes: 1