apk中的颜色是来自Android模拟器的偶数
这是我的Android Studio Emulator屏幕截图
,这是我的手机同一应用APK格式屏幕截图 cardView颜色的apk格式不同 有所
不同
textView颜色也
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_screen_content_background_color"
android:orientation="vertical"
android:padding="@dimen/main_screen_content_padding"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_main"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/snowflake" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Weather" />
<TextView
android:id="@+id/tv_main_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="condition" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_humidity"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/humidity" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_temp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Degree" />
<TextView
android:id="@+id/tv_humidity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="per cent" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/card_view_marginTop"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_min_max"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/temperature" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_min"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Minimum" />
<TextView
android:id="@+id/tv_max"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Maximum" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_wind"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/wind" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_speed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Wind" />
<TextView
android:id="@+id/tv_speed_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/miles_per_hour"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginTop="@dimen/card_view_marginTop"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="@dimen/card_view_content_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_location"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/location" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Name" />
<TextView
android:id="@+id/tv_country"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Country" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"
android:layout_margin="@dimen/divider_margin"
android:background="@color/divider_background" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/sunrise_marginTop"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_sunrise"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/sunrise" />
<TextView
android:id="@+id/tv_sunrise_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Sunrise" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/sunset_marginStart"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_sunset"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/sunset" />
<TextView
android:id="@+id/tv_sunset_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Sunset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
另外,
this is my android studio emulator screenshot
and this is my phone same app apk format screenshot
cardview colors is different in apk format
also textview colors are also different
this problem is happens in every app made my me
my xml file is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_screen_content_background_color"
android:orientation="vertical"
android:padding="@dimen/main_screen_content_padding"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_main"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/snowflake" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Weather" />
<TextView
android:id="@+id/tv_main_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="condition" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_humidity"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/humidity" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_temp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Degree" />
<TextView
android:id="@+id/tv_humidity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="per cent" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/card_view_marginTop"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_min_max"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/temperature" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_min"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Minimum" />
<TextView
android:id="@+id/tv_max"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Maximum" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:layout_weight="1"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/card_view_content_padding">
<ImageView
android:id="@+id/iv_wind"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/wind" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_speed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Wind" />
<TextView
android:id="@+id/tv_speed_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/miles_per_hour"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_view_marginStartEnd"
android:layout_marginTop="@dimen/card_view_marginTop"
android:layout_marginEnd="@dimen/card_view_marginStartEnd"
android:background="@android:color/white"
app:cardCornerRadius="@dimen/card_view_corner_radius"
app:cardElevation="@dimen/card_view_elevation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="@dimen/card_view_content_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_location"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/location" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/primary_text_color"
android:textSize="@dimen/label_text_size"
android:textStyle="bold"
tools:text="Name" />
<TextView
android:id="@+id/tv_country"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Country" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/divider_height"
android:layout_margin="@dimen/divider_margin"
android:background="@color/divider_background" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/sunrise_marginTop"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_sunrise"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/sunrise" />
<TextView
android:id="@+id/tv_sunrise_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Sunrise" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/sunset_marginStart"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_sunset"
android:layout_width="@dimen/identification_image_size"
android:layout_height="@dimen/identification_image_size"
android:layout_marginEnd="@dimen/identification_image_marginEnd"
android:contentDescription="@string/image_contentDescription"
app:srcCompat="@drawable/sunset" />
<TextView
android:id="@+id/tv_sunset_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text_color"
android:textSize="@dimen/value_text_size"
tools:text="Sunset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
WAITING FOR AN EARLY RESPONSE THANK U
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的手机可能处于黑暗模式,这就是导致颜色差异的原因。之所以发生这种情况,是因为您的应用程序的主题支持轻型和深色模式。您实际上可以在Android Studio中将预览窗口设置为“黑暗”模式。
另外,切断
cardView
s底部的快速修复是将useCompatPadding =“ true”
向每个添加。Your phone is likely in dark mode, and this is what's causing the color differences. This is happening because your app's theme supports both light and dark modes. You can actually set the preview window in Android Studio to dark mode if you want.
Also, a quick fix for the bottoms of your
CardView
s being cut off is to adduseCompatPadding="true"
to each one.