我正在尝试在kotlin中创建一个简单的未绑定服务,但我不能.当我onBind()在Java中覆盖方法时我可以返回null,但在kotlin中它说我只允许返回IBinder而不是IBinder?,这意味着它不能null.除了将MyService类重写为Java之外,有什么想法可以解决这个问题吗?
[已解决]谢谢,伙计们!我真的可以IBinder改为IBinder?.有用!!
我有一个问题与CardView在RecyclerView.我CardView突然变黑了,RatingBar变成了蓝色.我正在使用InfiniteRecyclerView但改变它简单RecyclerView没有效果.我可以将CardView背景颜色改为白色,但RatingBar仍然是蓝色.这是正在发生的事情的一个例子:
我使用RecyclerView相同适配器的片段中的另一个活动中的法线,它看起来很好.这是一个例子:
这是single_recipe_recycler_item.xml布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:id="@+id/recipe_recycler_image"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp">
<!-- RealmRecipe Title -->
<TextView
android:id="@+id/recipe_recycler_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="end"
android:text="Very very very very very very long title"
android:textColor="@color/colorBlack"
android:textSize="@dimen/title"
android:textStyle="bold" />
<!-- Publisher --> …Run Code Online (Sandbox Code Playgroud) 我有一个 Row 有 2 个这样的孩子:
----------------------
| wide child1 | child2 |
----------------------
Run Code Online (Sandbox Code Playgroud)
有什么方法可以使每个单元格的大小相等,以便每个单元格的宽度等于最宽单元格的宽度?像这样:
--------------------------
| wide child1 | child2 |
--------------------------
Run Code Online (Sandbox Code Playgroud)
所以整个 Row 都会占用biggestCellWidth * numOfChildren宽度。
我无法使用内置小部件实现此行为并尝试实现 MultiChildLayoutDelegate但它也不起作用,因为我无法测量孩子。
更新:
----------------------
| wide child1 | child2 |
----------------------
Run Code Online (Sandbox Code Playgroud)