小编Joc*_*Doe的帖子

删除高程阴影而不删除高程本身

AppBarLayout没有办法让没有阴影并保持其高度?

<android.support.design.widget.AppBarLayout
        app:elevation="0dp">
Run Code Online (Sandbox Code Playgroud)

android shadow android-toolbar android-elevation android-appbarlayout

26
推荐指数
2
解决办法
4457
查看次数

在kotlin中实现接口的Lambda

什么是相当于kotlin中的代码,似乎没有什么工作我尝试:

public interface AnInterface {
    void doSmth(MyClass inst, int num);
}
Run Code Online (Sandbox Code Playgroud)

在里面:

AnInterface impl = (inst, num) -> {
    //...
}
Run Code Online (Sandbox Code Playgroud)

java methods lambda interface kotlin

23
推荐指数
2
解决办法
6142
查看次数

Kotlin检查了例外情况

由于Kotlin不支持检查异常,因此如何让程序员意识到方法可能会抛出异常

简单的例子:

class Calculator (value: Int = 0) {

    fun divide (dividend: BigDecimal, divider: BigDecimal) : BigDecimal {
        return dividend / divider
    }
}
Run Code Online (Sandbox Code Playgroud)

显然,divide方法可能抛出java.lang.ArithmeticException: Division by zero异常,并且库的创建者需要警告类的用户将调用放在try-catch子句中

在Kotlin,这种意识的机制是什么?

java exception try-catch kotlin

14
推荐指数
1
解决办法
2748
查看次数

验证值有两种可能的类型

当请求值应该是字符串或数组都有效时,如何验证它?

'val' => 'bail|required|string'
'val' => 'bail|required|array'
Run Code Online (Sandbox Code Playgroud)

验证表达式是什么?

php validation request laravel

6
推荐指数
2
解决办法
1937
查看次数

折叠工具栏布局和约束布局

我正在努力与Constraint一起创建折叠的图像标题,其中我的设计看起来像这样

在此处输入图片说明

目前,个人资料图片是的一部分,ConstraintLayout因为它需要准则约束,但不幸的是,它与AppBarLayout

有什么想法要实现吗?找不到关于我的布局组合的任何来源.....

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/playerViewBg"
        android:fitsSystemWindows="false">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/bgIV"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:src="@drawable/header_bg" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/playerIV"
            android:layout_width="177dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginTop="62dp"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:src="@drawable/profilePic"
            app:layout_constraintEnd_toStartOf="@+id/guideline2"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintStart_toStartOf="@+id/guideline"
            app:layout_constraintTop_toTopOf="parent" />

        <!-- Other content -->

        <android.support.constraint.Guideline
            android:id="@+id/guideline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.27" />

          <android.support.constraint.Guideline
            android:id="@+id/guideline2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.73" />

    </android.support.constraint.ConstraintLayout>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android overlapping android-coordinatorlayout android-collapsingtoolbarlayout android-constraintlayout

5
推荐指数
1
解决办法
5136
查看次数

确定ScaleAnimation枢轴

我有一个视图,我正在缩放列表,模拟列表项垂直缩放到全屏.

这里的例子GitHub的项目发挥与动画代码是在这里

在此输入图像描述

代码如下所示:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        android:id="@+id/growView"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/fiftyBlack" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

view.setOnClickListener {

    val listItemHeight = it.measuredHeight
    val toolBarHeight = (it.parent as RecyclerView).y
    val scalingView = it.rootView.findViewById<View>(R.id.growView)
    val screenHeight = (scalingView.parent as FrameLayout).measuredHeight

    // Position the view exactly over the list item
    scalingView.y = it.y + toolBarHeight
    scalingView.layoutParams.height = listItemHeight
    scalingView.layoutParams = scalingView.layoutParams

    /* 
      pivots[0] scales example animation for the first item of the list 
      for xxhdpi: 1080p device
      for the rest of …
Run Code Online (Sandbox Code Playgroud)

java animation android scale kotlin

5
推荐指数
0
解决办法
235
查看次数

获取用于解析嵌套 Parcelable 泛型字段的泛型类加载器

我有一个Parcelable泛型类型的包装器,但Parcel构造无法编译,因为T无法泛型确定类

class MyItem<T : Parcelable> (val model: T) : Parcelable {
    constructor(parcel: Parcel) : 
      this(parcel.readParcelable(T::class.java.classLoader)) {

    }
}
Run Code Online (Sandbox Code Playgroud)

这个案例有什么解决办法吗?

generics android parcelable kotlin

1
推荐指数
1
解决办法
2552
查看次数