2017-06-13 89 views
2

你好,我開始Android,我有這個問題。當我在API 23上運行我的應用程序這個cardview正顯示出這樣API 23活動主題無法正確顯示

應該顯示我有在Android 5.0

這裏同樣的問題,這樣The same application on API 24

是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> 

主題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)cardview的

<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> 
+0

發表你對你所定義 – Pulak

+0

我覺得版本styles.xml在樣式出現問題 – Raj

回答

1

改變背景色:

card_view:cardBackgroundColor="@android:color/white" 
+0

工作正常,但上面的cardview和spinner的旋轉器未顯示文本。有沒有什麼財產可以解決這個問題? – Tico1993

+0

如果有幫助,接受爲正確。 檢查此鏈接:https://stackoverflow.com/questions/9476665/how-to-change-spinner-text-size-and-text-color 你可以在微調框中設置自定義的textView。 –