gpt4 book ai didi

android - cardview 的最后一行未在所有设备中显示

转载 作者:搜寻专家 更新时间:2023-11-01 09:26:41 26 4
gpt4 key购买 nike

我在一个 android 应用程序中工作,在这个应用程序中我有 cardview,我的问题是当我运行该应用程序时它工作正常但是 cardview 的最后一行没有正确显示。

我检查了几个模拟器设备,它在所有设备中显示相同。

请帮我解决这个问题。

cardview.xml

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
cardview:cardElevation="5dp"
cardview:cardUseCompatPadding="true"
cardview:cardCornerRadius="10dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ImageView
android:id="@+id/mReminder_Image_Id"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:scaleType="fitXY"
android:background="#ffffff"/>
<TextView
android:id="@+id/mReminder_Text_Id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#2d2d2d"
android:textSize="13sp"
android:text="Reminder texts"/>
</LinearLayout>
</android.support.v7.widget.CardView>

fragment_reminders.xml

<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:orientation="vertical"
tools:context=".Fragments.Reminders">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reminders"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="@color/tab_background"
android:layout_gravity="center" />
</android.support.v7.widget.Toolbar>

<android.support.v7.widget.RecyclerView
android:id="@+id/mRecyclerView_id"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>

</LinearLayout>

activity_main.xml

<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/Conslayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"

android:animateLayoutChanges="true"
android:layoutMode="opticalBounds"
android:background="?android:attr/windowBackground"

app:itemBackground="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation"
app:itemIconTint="@color/color_selector"
app:itemTextColor="@color/color_selector" />

</android.support.constraint.ConstraintLayout>

最佳答案

以此替换您的 Activity 主要布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"

android:animateLayoutChanges="true"
android:background="?android:attr/windowBackground"
android:layoutMode="opticalBounds"

app:itemBackground="?android:attr/windowBackground"
app:itemIconTint="@color/color_selector"
app:itemTextColor="@color/color_selector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />

</LinearLayout>

解释:

您的 BottomNavigationView 与您的 FrameLayout 重叠。我用 LinearLayout 而不是 ContraintLayout 包装你的 View 来使用权重,只是给 FrameLayout 权重 1,所以它占据了底部导航上方的可用空间。

关于android - cardview 的最后一行未在所有设备中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50105718/

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