Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ImageButton没有';t在cardview上重叠,但正常按钮//图像按钮不在cardview上重叠,在正常按钮下方重叠_Java_Android_Android Layout - Fatal编程技术网

Java ImageButton没有';t在cardview上重叠,但正常按钮//图像按钮不在cardview上重叠,在正常按钮下方重叠

Java ImageButton没有';t在cardview上重叠,但正常按钮//图像按钮不在cardview上重叠,在正常按钮下方重叠,java,android,android-layout,Java,Android,Android Layout,我正在开发一个应用程序,在某个时候它会显示一些“学习表”。问题是,对于每个项目,它都应该显示两个按钮,这两个按钮应该在cardview上重叠,但只有当使用imagebutton时,它才与普通按钮一起工作,而不与imagebutton一起工作 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" an

我正在开发一个应用程序,在某个时候它会显示一些“学习表”。问题是,对于每个项目,它都应该显示两个按钮,这两个按钮应该在cardview上重叠,但只有当使用imagebutton时,它才与普通按钮一起工作,而不与imagebutton一起工作

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.v7.widget.CardView
        android:id="@+id/sheet_card_view"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="32dp"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="32dp"
        android:elevation="8dp"
        app:cardCornerRadius="8dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="8dp"
            android:background="?android:attr/selectableItemBackground">

            <TextView
                android:id="@+id/sheet_text_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_centerHorizontal="true"
                android:text="SAMPLE OF CONTENT.SAMPLE OF CONTENT.SAMPLE OF CONTENT.SAMPLE OF CONTENT"
                android:textSize="15sp"
                android:autoSizeMinTextSize="10sp"
                android:autoSizeMaxTextSize="20sp"
                android:autoSizeStepGranularity="2sp"/>

        </RelativeLayout>

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

    <ImageButton
        android:id="@+id/sheet_flip_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@id/sheet_card_view"
        android:layout_marginTop="-32dp"
        android:layout_marginRight="20dp"
        android:src="@drawable/ic_flip_white_24dp"/>

    <Button
        android:id="@+id/sheet_show_image_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignBottom="@id/sheet_card_view"
        android:layout_marginBottom="-32dp"
        android:layout_marginLeft="20dp"/>

</RelativeLayout>


按钮
在材质主题下有默认的标高(实际上,当按钮启用时,它有一个提供标高的按钮),而
图像按钮
没有,因此您必须自己添加
标高。

将标高添加到
图像视图

    android:elevation="10dp"
您的卡高度为
8dp
,请将
10dp
高度添加到
ImageView

    android:elevation="10dp"

现在您的
ImageView
将重叠
cardwiew

我怀疑
elevation
就是答案。正常的
按钮
s内置了仰角,但是
ImageButton
不是
按钮
,所以可能不是。尝试将
android:elevation=“10dp”
添加到ImageButton标签。谢谢,该解决方案解决了我遇到的问题
    android:elevation="10dp"