java - Android 4.4 上的 Material

标签 java android material-design

我正在使用 Android Studio 2.3.3 开发我的应用程序,任何元素都在 Android 7 上采用 Material Design,但如果在 Android 4.4 上运行应用程序,元素的位置和样式会发生变化。

Constraint Layout

在 7.1.1 上运行

enter image description here

在 4.4 上运行

enter image description here

我知道 Android 4 不支持 Material design 除了第三方项目,但我想了解为什么位置会发生变化。

任何想法或修复?

<?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:gravity="center"
        tools:context="com.scannerproject.MainActivity"
        android:layout_weight="1"
        tools:layout_editor_absoluteY="0dp"
        tools:layout_editor_absoluteX="0dp">

 <Button
        android:id="@+id/button"
        android:layout_width="243dp"
        android:layout_height="47dp"
        android:background="@color/colorPrimary"
        android:onClick="scan"
        android:text="SCANSIONE"
        android:textColor="#fff"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.504"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.457" />    

    <Switch
            android:id="@+id/flash"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Attiva Flash"
            android:layout_marginRight="8dp"
            app:layout_constraintRight_toRightOf="@+id/button"
            android:layout_marginLeft="8dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginBottom="8dp"
            app:layout_constraintVertical_bias="0.555" />

    </android.support.constraint.ConstraintLayout>

最佳答案

小修复,用右键指向右边的开关

enter image description here

关于java - Android 4.4 上的 Material ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46862646/

相关文章:

android - 带有分页架构组件的初始占位符

javascript - JS 模块 - ReferenceError : <function> is not defined

android - 如何在Android中的Material Button上使用光波纹

java - 需要帮助计算 MaxHeap 中的交换数量

Android Firebase,只需获取一个子对象的数据

java - 每当实例化类时如何实现该类的方法?

android - 解析一对多关系

css - 将 Materials-UI 添加到 Spring + thymeleaf 元素

java - 跨线程访问异常: How to implement?

Java 应用程序 + 日志记录