android视图背景颜色的代码,android–按代码更改Recycler视图项背景...

android视图背景颜色的代码,android–按代码更改Recycler视图项背景...

2023年7月13日发(作者:)

android视图背景颜⾊的代码,android–按代码更改Recycler视图项背景颜⾊我想更改RecyclerView项⽬的背景颜⾊.我想我应该可以在onBindViewHolder⽅法中做到这⼀点,但我⽆法做到这⼀点.我只更改了项⽬的底部边框颜⾊,但我想更改完整的背景颜⾊这就是我想要的public void onBindViewHolder(lder holder, int position) {if (//Some Condition) {kgroundColor();}else {kgroundColor();}}我认为这应该产⽣类似的东西我得到的就是这个这是我的RecyclerView Fragment roid:orientation="vertical" android:layout_width="match_parent"xmlns:app="/apk/res-auto"android:layout_height="match_parent">android:layout_width="match_parent"android:layout_height="match_parent"app:layout_behavior="@string/appbar_scrolling_view_behavior"android:id="@+id/installed_recyclerView"android:paddingTop="1dp">这是我的项⽬布局⽂件android:orientation="vertical" android:layout_width="match_parent"android:layout_height="wrap_content"android:elevation="3dp"android:paddingBottom="1dp"android:clickable="true"android:focusable="true"android:focusableInTouchMode="true">xmlns:card_view="/apk/res-auto"android:id="@+id/post_card_view"android:layout_gravity="center"android:layout_width="match_parent"android:layout_height="wrap_content"card_view:cardCornerRadius="1dp">android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical">android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Arial New"android:id="@+id/installed_font_name"android:textSize="16dp"/>android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Monotype Solutions"android:textSize="12dp"android:id="@+id/installed_preview_company_name"/>android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Preview Test"android:id="@+id/installed_preview_textview"android:textSize="30dp"/>android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal">android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"/>android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:paddingRight="10dp"android:gravity="center"android:id="@+id/installed_preview_Unnstall">android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/ic_remove_circle_24dp"android:background="@android:color/transparent"android:tint="@android:color/holo_red_light"/>android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Uninstall"android:textSize="12dp"/>android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:paddingRight="10dp"android:gravity="center"android:id="@+id/installed_preview_flip_layout">android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/ic_autorenew_24dp"android:background="@android:color/transparent"android:tint="@android:color/holo_blue_dark"/>android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Flip This"android:textSize="12dp"/>解决⽅法:请尝试更改onBindViewHolder中的代码,如下所⽰if(// Any Condition) {((CardView)_card_view).setCardBackgroundColor();}else{((CardView)_card_view).setCardBackgroundColor();}我希望这会对你有所帮助,请随意发表评论.标签:android,android-recyclerview

发布者:admin,转转请注明出处:http://www.yc00.com/news/1689215961a222269.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信