Android API小于21的抽头涟漪效应
你好,我是科特林的新手,我一直面临着一个非常奇怪的问题。我有一个简单的ListView,里面填充了一些子布局! 我的XML ListView标记是:Android API小于21的抽头涟漪效应,android,kotlin,android-relativelayout,ripple,Android,Kotlin,Android Relativelayout,Ripple,你好,我是科特林的新手,我一直面临着一个非常奇怪的问题。我有一个简单的ListView,里面填充了一些子布局! 我的XML ListView标记是: <ListView android:id="@+id/invoicesList" android:layout_width="match_parent" android:layout_height="match_parent"
<ListView
android:id="@+id/invoicesList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:dividerHeight="0dp"/>
在所需的布局上!
但是,每当我在id=ripple的相对布局上注册任何单击侦听器时,它就会停止显示连锁反应
我正在使用Android 5.0棒棒糖在LG G3上进行测试,我希望Android版本为19+的Android设备能够显示连锁反应
我必须使用
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
为了显示连锁反应,有人能帮我指出我做错了什么吗?提前谢谢 试试
?attr/selectableitembackgroundless
看看这个:也试过了,不起作用。我想问题可能出在你的com.es.b2bbakcell.widgets.textwidts.BakcellTextViewNormal视图上。我用android:background=“?android:attr/selectableItemBackground”更改了简单文本视图的这些项目,并对列表中的每个项目产生了涟漪效应。在安卓8.0上测试。在安卓4.4上测试-不工作。我认为它不应该在Android API<21上工作。显然,涟漪效应仅限于API 21及以上版本。它需要21+Android版本。不,它不需要。我在一个应用程序中使用了它,这个应用程序有17个页面,是不是布局被其他视图弄乱了,而你就是看不到涟漪?
<?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">
<!--nested container-->
<RelativeLayout
android:id="@+id/ripple"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/_10sdp"
android:paddingTop="@dimen/_10sdp">
<RelativeLayout
android:id="@+id/childLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_20sdp"
android:layout_marginRight="@dimen/_20sdp"
android:orientation="horizontal">
<!--col1-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.es.b2bbakcell.widgets.textwidgets.BakcellTextViewNormal
android:id="@+id/serviceValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Blackberry Service"
android:textColor="@color/colorTextGray"
android:textSize="@dimen/_10ssp"/>
</RelativeLayout>
</LinearLayout>
<!--col2-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.es.b2bbakcell.widgets.textwidgets.BakcellTextViewNormal
android:id="@+id/miqdarValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="12345"
android:textColor="@color/colorTextGray"
android:textSize="@dimen/_10ssp"/>
</RelativeLayout>
</LinearLayout>
<!--col3-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.9">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.es.b2bbakcell.widgets.textwidgets.BakcellTextViewNormal
android:id="@+id/vahidValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="saat:den:san"
android:textColor="@color/colorTextGray"
android:textSize="@dimen/_10ssp"/>
</RelativeLayout>
</LinearLayout>
<!--col4-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.es.b2bbakcell.widgets.textwidgets.BakcellTextViewNormal
android:id="@+id/mablaqValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="98.2"
android:textColor="@color/colorTextGray"
android:textSize="@dimen/_10ssp"/>
</RelativeLayout>
</LinearLayout>
<!--col5-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3.3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.es.b2bbakcell.widgets.textwidgets.BakcellTextViewNormal
android:id="@+id/endirimValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="0.0"
android:textColor="@color/colorTextBlack"
android:textSize="@dimen/_10ssp"/>
</RelativeLayout>
</LinearLayout>
<!--col6-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.es.b2bbakcell.widgets.textwidgets.BakcellTextViewNormal
android:id="@+id/camiValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="1125.7"
android:textColor="@color/colorTextBlack"
android:textSize="@dimen/_10ssp"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!--//nested container-->
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/ripple"
android:layout_marginLeft="@dimen/_45sdp"
android:layout_marginRight="@dimen/_45sdp"
android:background="@color/colorSeperator"></View>
</RelativeLayout>
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"