Why v7 package

 v7 package: 1. Ensure that 5.0 or more and 5.0 or less consistent effects controls
 2. ensure low and high style version uses the same version of the same style theme

https://blog.csdn.net/qq_31001287/article/details/60867484

    <color name = "colorPrimary"> # 17c782 </ color> // color navigation
    <color name = "colorPrimaryDark"> # 17c782 </ color> // status bar color
    <color name = "colorAccent"> # 17c782 </ color> // control the color theme
    <color name = "windowBackground"> # d9d9d9 </ color> // default screen background color
    <color name = "textColorPrimary"> # 333333 </ color> // the default text color theme

It must play a role in 5.0 above, material design5.0 introduced

<?xml version="1.0" encoding="utf-8"?>


<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/srl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto" >


<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="org.xm.recyclerviewsimple.TestActivity">



   <!-- <ImageView
        android:id="@+id/image_item_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        />-->

<!-- 使用系统内置的Dialog:android.app.AlertDialog -->
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="41dp"
        android:text="Button"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="87dp"
        android:layout_marginStart="87dp"
        android:onClick="showMessag"/>


  <!-- 使用系统内置的CheckBox -->

    <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/button"
        android:layout_alignRight="@+id/button"
        android:layout_below="@+id/button"
        android:layout_marginEnd="19dp"
        android:layout_marginRight="19dp"
        android:layout_marginTop="117dp"
        android:text="CheckBox" />

    <!--android.support.v7.widget.AppCompatEditText -->
    <!-- android.support.v7.widget.AppCompatCheckBox-->
  <!-- 使用系统内置的EditButton -->
    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/checkBox"
        android:layout_alignLeft="@+id/checkBox"
        android:layout_alignStart="@+id/checkBox"
        android:layout_marginBottom="43dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Name" />

    <!-- 5.0以下和5.0以上即使使用Widget.AppCompat.ProgressBar也是有区别,需要自定义 -->
    <ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/checkBox"
        android:layout_alignStart="@+id/checkBox"
        android:layout_below="@+id/checkBox"
        android:layout_marginTop="10dp" />





</RelativeLayout>

</ScrollView>


</android.support.v4.widget.SwipeRefreshLayout>

4.4 Effect:

 The figure on the left is a 4.4 simulator, the right is the 5.0 simulator, it is clear that the same style, how to ensure the same style under 4.4 and 5.0+, use v7 package under the control replacement,

<?xml version="1.0" encoding="utf-8"?>


<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/srl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto" >


<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="org.xm.recyclerviewsimple.TestActivity">



   <!-- <ImageView
        android:id="@+id/image_item_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        />-->

   <!--android.support.v7.app.AlertDialog 
   public  void showMessag(View view){
        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        builder.setTitle("女朋友");
        builder.setMessage("给我一个女朋友");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });

        builder.show();
    }-->
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="41dp"
        android:text="Button"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="87dp"
        android:layout_marginStart="87dp"
        android:onClick="showMessag"/>

    <android.support.v7.widget.AppCompatCheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/button"
        android:layout_alignRight="@+id/button"
        android:layout_below="@+id/button"
        android:layout_marginEnd="19dp"
        android:layout_marginRight="19dp"
        android:layout_marginTop="350dp"
        android:text="CheckBox" />

    <!--android.support.v7.widget.AppCompatEditText -->
    <!-- android.support.v7.widget.AppCompatCheckBox-->

    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/checkBox"
        android:layout_alignLeft="@+id/checkBox"
        android:layout_alignStart="@+id/checkBox"
        android:layout_marginBottom="43dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Name" />

    <!-- 5.0以下和5.0以上即使使用Widget.AppCompat.ProgressBar也是有区别,需要自定义 -->
    <ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/checkBox"
        android:layout_alignStart="@+id/checkBox"
        android:layout_below="@+id/checkBox"
        android:layout_marginTop="10dp" />
</RelativeLayout>

</ScrollView>


</android.support.v4.widget.SwipeRefreshLayout>

4.4 5.0 emulator and simulator consistent effects

Published 141 original articles · won praise 51 · views 90000 +

Guess you like

Origin blog.csdn.net/dreams_deng/article/details/83144766