2016-07-22 1 views
1

CardViewを使用して作成されたRecyclerViewリストアイテムは、異なるアンドロイドバージョンでは等しくありません。タブと同じです。各デバイスで同じように見えるようにするにはどうすればよいですか?アンドロイドの以前のバージョンでは、CardViewとタブのデザインが異なります

のGradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.3' 

    defaultConfig { 
     applicationId "com.example.marat.days" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.android.support:support-v4:23.4.0' 
    compile 'com.android.support:percent:23.4.0' 
    compile 'com.android.support:cardview-v7:23.4.0' 
    compile 'com.android.support:recyclerview-v7:23.4.0' 
} 

list_item.xml:

<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="wrap_content" 
    android:layout_marginLeft="12dp" 
    android:layout_marginRight="12dp" 
    android:layout_marginTop="10dp" 
    android:layout_marginBottom="10dp" 
    android:clickable="true" 
    android:focusable="true" 
    android:foreground="?android:attr/selectableItemBackground" 
    card_view:cardElevation="5dp" 
    card_view:cardCornerRadius="20dp"> 

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:baselineAligned="false"> 

      // other lines of code 
      // if you need it let me know 

     </LinearLayout> 

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

アンドロイド4のAndroid 6.0

enter image description here

に。 4

enter image description here

のAndroid 4.4上(cardCornerRadius属性アウト付き)

enter image description here

答えて

2

呼び出してみてください。あなたのCardViewにsetPreventCornerOverlap(false/true);

はこちらをご参照:https://medium.com/@etiennelawlor/layout-tips-for-pre-and-post-lollipop-bcb2e4cdd6b2#.89mmrla2j

注意:あなたはまた、どのようにあなたがそれを見つけたcardview:cardUseCompatPadding="true/false"

+0

XML でこの属性を設定することができますか?あなたは私の時間を救った。ありがとうございました!!! – Marat

+0

タブのデザインを手伝ってもらえたら幸いです。なぜ古いバージョンでは分離線がありますが、アンドロイド6.0ではそうではありません。 – Marat

関連する問題