Support Library 28.0alpha1을 시도했습니다.

14870 단어 Android
※ 잘못이 있으면 지적해 주십시오.
Note: 28.0.0-alpha1 is a pre-release version to support the Android P developer preview. Its API surface is subject to change, and it does not necessarily include features or bug fixes from the latest stable versions of Support Library. For details on the P developer preview, see the release notes.

이번에 시도한 것들.


Design Library

  • BottomAppBar
  • Chip
  • ChipGroup
  • MaterialButton
  • MaterialCardView

  • 설정


    app/build.gradle
    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    
    android {
        compileSdkVersion 'android-P'
        buildToolsVersion "28.0.0-rc1"
        defaultConfig {
            applicationId "com.github.atsumo.myapplication"
            minSdkVersion 'P'
            targetSdkVersion 'P'
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:design:28.0.0-alpha1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    
    
    

    BottomAppBar

    <android.support.design.bottomappbar.BottomAppBar
            android:id="@+id/bottomappbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="bottom"
            app:backgroundTint="@color/colorPrimary"
            app:fabAlignmentMode="end"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            />
    
    <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fabSize="normal"
            app:layout_anchor="@+id/bottomappbar"
            app:srcCompat="@android:drawable/ic_dialog_email"
            />
    
    fabAlignmentMode 오목함을 만들 위치를 지정합니다.
    전용 center/end레이아웃 추기앙코르를 사용하면 오목함을 잘 준다는 평을 받아 수정했다.app:layout_anchor="@+id/bottomappbar"

    Chip/ChipGroup



    Choice3을 선택한 상태에서 초기화된 샘플app:singleSelection="true" 이것은 어느 것을 선택된 상태로 만들었는가
    <!-- ChipGroup single selection -->
        <android.support.design.chip.ChipGroup
            android:id="@+id/chipGroup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:checkedChip="@+id/choice3"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:singleSelection="true"
            >
    
            <android.support.design.chip.Chip
                android:id="@+id/choice1"
                style="@style/Widget.MaterialComponents.Chip.Choice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Choice1"
                />
    
            <android.support.design.chip.Chip
                android:id="@+id/choice2"
                style="@style/Widget.MaterialComponents.Chip.Choice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Choice2"
                />
    
            <android.support.design.chip.Chip
                android:id="@+id/choice3"
                style="@style/Widget.MaterialComponents.Chip.Choice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Choice3"
                />
    
            <android.support.design.chip.Chip
                android:id="@+id/choice4"
                style="@style/Widget.MaterialComponents.Chip.Choice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Choice4"
                />
        </android.support.design.chip.ChipGroup>
    
    
    치프 콘셉트가 4가지가 있어요.
  • Action(Default)
  • Choice
  • Entry
  • Filter
  • <android.support.design.chip.ChipGroup
            android:id="@+id/chipGroup2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/chipGroup"
            app:singleLine="true"
            >
    
            <android.support.design.chip.Chip
                style="@style/Widget.MaterialComponents.Chip.Action"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipIcon="@drawable/ic_android_black_24dp"
                app:chipText="Action"
                />
    
            <android.support.design.chip.Chip
                style="@style/Widget.MaterialComponents.Chip.Filter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Filter"
                />
    
            <android.support.design.chip.Chip
                style="@style/Widget.MaterialComponents.Chip.Choice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Choice"
                />
    
            <android.support.design.chip.Chip
                style="@style/Widget.MaterialComponents.Chip.Entry"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:chipText="Entry"
                />
    </android.support.design.chip.ChipGroup>
    
    

    MaterialCardView


    CardView와 비교하면 어떻게 달라졌습니까?
    stroke Color/Stroke Width가 추가되었습니까?
    ※ 다시 한 번

    MaterialButton


    <android.support.design.button.MaterialButton
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:gravity="center_vertical"
            android:text="MaterialButton"
            android:textColor="#FFFFFF"
            app:cornerRadius="16dp"
            app:icon="@drawable/ic_android_black_24dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            />  
    
    다음 두 가지를 지정할 수 있는 것은
  • cornerRadius
  • icon
  • rippleColor를 지목할 수도 있지만 아무래도 잘 안되는 것 같아서 다음에 얘기하자

    한마디


    대충 해본 거니까 잘못된 점이나 원래 새로운 곳이 아니라는 지적이 있으면 알려주세요.
    안드로이드-P의 총결산도 며칠 앞으로 다가온다.

    좋은 웹페이지 즐겨찾기