Java ImageButton没有';t在cardview上重叠,但正常按钮//图像按钮不在cardview上重叠,在正常按钮下方重叠
我正在开发一个应用程序,在某个时候它会显示一些“学习表”。问题是,对于每个项目,它都应该显示两个按钮,这两个按钮应该在cardview上重叠,但只有当使用imagebutton时,它才与普通按钮一起工作,而不与imagebutton一起工作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
<?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"