gpt4 book ai didi

android - CardView 在 API 19 上消失

转载 作者:行者123 更新时间:2023-11-29 17:41:47 25 4
gpt4 key购买 nike

我开发了一款可以在 Lollipop 上完美运行的应用程序。但是,我在 kitkat (api 19) 上遇到了一些奇怪的故障

当我在 kitkat 设备上运行我的应用程序时,它会显示我的卡片 View 一瞬间然后消失。

下面是我的 xml 布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
xmlns:fontawesometext="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context="com.running.mattboyle.runnertoolbox.RunningMap">


<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_viewrunning"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"

android:background="@drawable/backgroundcard"
card_view:cardCornerRadius="4dp">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<Chronometer
android:id="@+id/Duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:paddingLeft="10dp"
android:text="0:00"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/Calories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:layout_marginTop="60dp"
android:text="Calories: 0" />
<TextView
android:id="@+id/pace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_alignParentRight="true"
android:text="0:00"
android:layout_marginEnd="60dp" />

<TextView
android:id="@+id/paceunits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:text="min/km"
android:layout_alignParentRight="true"
android:layout_marginEnd="10dp" />

<TextView
android:id="@+id/distanceText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@id/Duration"
android:layout_marginTop="52dp"
android:text="0.00"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/distanceUnits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/Duration"
android:layout_marginTop="12dp"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@id/distanceText"
android:text="KM"
android:textAppearance="?android:attr/textAppearanceMedium" />


</RelativeLayout>


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

<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/runButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:text="Begin Run"
android:layout_centerInParent="true"

bootstrap:bb_type="primary" />


<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/pauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:text="Pause"
android:layout_centerHorizontal="true"
android:paddingRight="120dp"
bootstrap:bb_type="warning" />

<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/EndButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:paddingLeft="120dp"

android:text="End Run"
bootstrap:bb_type="success"

/>
</RelativeLayout>

<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:paddingBottom="40dp">

<com.beardedhen.androidbootstrap.BootstrapButton
android:id="@+id/right"
android:layout_width="70dp"
android:layout_margin="10dp"

android:layout_height="wrap_content"
bootstrap:bb_type="primary"
fontawesometext:fa_icon="fa-forward"
android:text="Next"
android:layout_alignParentRight="true"
android:layout_marginEnd="10dp" />

<TextView
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Calculating....."
android:id="@+id/runLength"
android:layout_centerHorizontal="true" />


<com.beardedhen.androidbootstrap.BootstrapButton
android:layout_width="70dp"
android:layout_height="wrap_content"
bootstrap:bb_type="primary"
android:text="Last"
fontawesometext:fa_icon="fa-backward"
android:id="@+id/left"
android:layout_alignParentLeft="true"
android:layout_marginStart="10dp" />


</RelativeLayout>

</RelativeLayout>


What's extra weird is I have a cardview on my home screen too that opens and works just fine:

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="@drawable/backgroundcard"
card_view:cardCornerRadius="4dp">

<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/vertical_divider"
android:dividerPadding="12dip"
android:showDividers="middle">

<TextView
android:id="@+id/weather"
android:textColor="@android:color/primary_text_light"

android:paddingTop="10dp"
android:paddingLeft="15dp"

android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Weather"
android:textSize="25dp"

/>

<TextView
android:id="@+id/location"
android:textColor="@android:color/darker_gray"

android:paddingTop="130dp"
android:paddingLeft="40dp"

android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Birmingham,UK"

/>


<ImageView
android:layout_width="130dp"
android:layout_height="130dp"
android:background="@drawable/nightcloud"
android:layout_marginTop="25dp"
android:layout_marginLeft="20dp"
android:layout_centerVertical="true"

android:id="@+id/weatherImage" />


<TextView
android:id="@+id/low"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="05\u00B0"
android:paddingTop="75dp"
android:paddingRight="20dp"
android:layout_alignParentEnd="true"
android:textColor="@android:color/primary_text_light"


/>

<TextView
android:id="@+id/high"
android:textColor="@android:color/primary_text_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10\u00B0"
android:paddingTop="95dp"
android:paddingRight="20dp"
android:layout_alignParentEnd="true" />

<TextView
android:id="@+id/current"

android:textColor="@android:color/darker_gray"
android:textSize="50dp"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10\u00B0"

android:paddingRight="50dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true" />

<TextView
android:id="@+id/judgement"


android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/darker_gray"

android:text="Wear an underlayer, it is cold!"
android:paddingBottom="5dp"
android:paddingLeft="15dp"

android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
</RelativeLayout>

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

Log cat 不提供任何投诉。

Android Studio 也对此进行了记录:

api 19API 19

api 21API 21

有什么想法吗?非常感谢任何帮助。

编辑:我尝试添加行 findViewById(R.id.card_viewrunning).setVisibility(View.VISIBLE);不占优势。

再一次,这在 api 21 设备上完美运行。很奇怪的一个。

最佳答案

查看 android studio 中右侧的组件树选项卡,了解您在 v19 中的布局。选择您的卡片 View 并查看可视化编辑器,它应该突出显示。我猜它隐藏在 fragment 后面。

关于android - CardView 在 API 19 上消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28466537/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com