ImageButton适用于其他布局,但对于TabLayout,它无法正常工作。我试图用CardView覆盖我的按钮,但它没有帮助。
<RelativeLayout
android:id="@+id/rl_tab_container"
android:layout_width="match_parent"
android:layout_height="@dimen/standard_bar_height"
>
<android.support.design.widget.TabLayout
android:id="@+id/tabs_dict"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:tabGravity="center"
app:tabSelectedTextColor="@color/colorBlack87"
app:tabTextColor="@color/colorBlack54"
app:tabIndicatorColor="@color/colorBlack87"
android:background="@color/colorPrimary"
/>
<ImageButton
android:id="@+id/button_delete_all_curr_dict"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_delete"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
/>
</RelativeLayout>
答案 0 :(得分:2)
在你的ImageButton上试试这个
android:clickable="true"
android:foreground="?attr/selectableItemBackground"