小编Asa*_*sad的帖子

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

如何将运动布局与 RecyclerView 结合使用

MotionLayout尝试与 一起使用RecyclerView,

向上滚动时,应用程序崩溃并出现错误:

android.content.res.Resources$NotFoundException:无法找到资源 ID #0xffffffff

片段布局代码是

<android.support.constraint.motion.MotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    app:layoutDescription="@xml/collapsing_config_order_details"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    ...

<android.support.v7.widget.CardView
        android:id="@+id/cardView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        app:layout_constraintEnd_toEndOf="@+id/tv_delivery_type"
        app:layout_constraintStart_toStartOf="@+id/imageView15"
        app:layout_constraintTop_toBottomOf="@+id/view4">

     ...

</android.support.v7.widget.CardView>

<android.support.v7.widget.RecyclerView
        android:id="@+id/rv_list"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/cardView"
        app:layout_constraintStart_toStartOf="@+id/cardView"
        app:layout_constraintTop_toBottomOf="@+id/cardView" />

</android.support.constraint.motion.MotionLayout>
Run Code Online (Sandbox Code Playgroud)

布局描述代码为:

<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Transition
        app:constraintSetEnd="@id/collapsed"
        app:constraintSetStart="@id/expanded">

        <OnSwipe
            app:dragDirection="dragUp"
            app:touchAnchorSide="top"
            app:moveWhenScrollAtTop="@+id/rv_list" />

    </Transition>

    <ConstraintSet android:id="@+id/expanded"
            android:id="@+id/cardView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="@+id/tv_delivery_type"
            app:layout_constraintStart_toStartOf="@+id/imageView15"
            app:layout_constraintTop_toBottomOf="@+id/view4" />
    </ConstraintSet>

    <ConstraintSet android:id="@+id/collapsed">
    <Constraint
            android:id="@+id/cardView"
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="@+id/tv_delivery_type"
            app:layout_constraintStart_toStartOf="@+id/imageView15"
            app:layout_constraintTop_toBottomOf="@+id/view4" />
    </ConstraintSet>

</MotionScene>
Run Code Online (Sandbox Code Playgroud)

android scroll swipe android-recyclerview android-motionlayout

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

如何使用 AudioSource.VOICE_CALL 录制语音通话

试图记录通话中,我使用MediaRecorder class使用时,AudioSource.MICAudioSource.VOICE_COMMUNICATION它的记录只有我的声音不是来自recevier,当我用AudioSource.VOICE_CALL它给例外的参加通话..这里是代码

if(intent.getAction().equals("android.intent.action.PHONE_STATE")){
            if((bundle = intent.getExtras()) != null){
                state = bundle.getString(TelephonyManager.EXTRA_STATE);
                if(state.equals(TelephonyManager.EXTRA_STATE_RINGING)){
                    inCall = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                    wasRinging = true;
                    Toast.makeText(context, inCall + " is calling", Toast.LENGTH_SHORT).show();
                }
                else if(state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)){
                    if(wasRinging){
                        Toast.makeText(context, "Call Answered", Toast.LENGTH_SHORT).show();
                        Date date = new Date();
                        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss");

                        String filename = "rec_" + format.format(date) + ".mp3";
                        String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getPath();
                        String fileUri = path + "/" + filename;
                        Log.v("testing uri", fileUri);
                        File file = new File(fileUri);

                        recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); …
Run Code Online (Sandbox Code Playgroud)

android recorder

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

如何垂直扩展Container中的TextField以覆盖Flutter中的所有可用空间

我想扩展 aTextField以垂直覆盖所有空间,它Container正在扩展但TextField没有扩展,这是设计:

蓝色是Container区域。但TextField没有扩大

在此处输入图片说明

这是我正在使用的代码:

Container(
      padding: EdgeInsets.all(16),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text("Title"),
          Container(
            margin: EdgeInsets.only(top: 8),
            child: TextField(
              controller: c_title,
              decoration: Styles.getInputFieldStyle(""),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: 16),
            child: Text("Feedback"),
          ),
          Expanded(
            child: Container(
              color: Colors.blue,
              margin: EdgeInsets.only(top: 8),
              child: TextField(
                decoration: Styles.getInputFieldStyle(""),
                controller: c_feedback,
                keyboardType: TextInputType.multiline,
              ),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: 16),
            width: double.infinity,
            child: RaisedButton(
              onPressed: (){_onSubmitPressed();},
              child: Text("Submit"),
              textColor: Colors.white,
              color: MyColors.theme_red,
            ),
          ) …
Run Code Online (Sandbox Code Playgroud)

expand textfield flutter flutter-layout

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