如何解决在 Framelayout 中,我有 1 个卡片视图和一个图像视图我想要卡片视图上的图像视图我想做的事
我试图在卡片视图上创建图像视图。所以我使用了Framelayout。在里面我添加了 1 cardview 之后我添加了一个图像视图。如果我使用 LinearLayout 而不是 cardview,则图像视图会通过线性布局进行查看。但是,如果我使用卡片视图,则图像视图不会超过卡片视图。请帮我 ... I have shown what I have
解决方法
把你的卡片视图放在 AnyLayout 中,比如 LinearLayout
<FrameLayout>
<LinearLayout>
<CardView/>
</LinearLayout>
<ImageView/>
</FrameLayout>
,
尝试以下内容:
<?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"
tools:context=".CustomGallery"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Dummy Text"
android:gravity="center"/>
<!-- Add more Views -->
<FrameLayout
android:layout_width="150dp"
android:layout_height="150dp"
android:clickable="true"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_gravity="center_horizontal">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="10dp"
app:cardElevation="0dp">
<!--<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/add_menu_item_logo"
android:scaleType="fitXY"
android:src="@drawable/ic_baseline_brightness_low_24"
/>-->
</androidx.cardview.widget.CardView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/add_menu_logo_placeholder">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_brightness_low_24"/>
</FrameLayout>
</FrameLayout>
</LinearLayout>
,
请像这样使用卡片视图
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardElevation="0dp"
android:elevation="0dp"
android:layout_centerInParent="true" />
注意重要的属性是 应用程序:cardElevation="0dp" 和 android:elevation="0dp" 它将高程设置为 0。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。