小编gio*_*ozh的帖子

在每个方向上缩放RectF对象

是否可以在每个方向上按任意因子缩放RectF对象?在实践中,我将调整RectF的2倍大小(如果RectF为200X200,则我将其变为100x100)

android scale android-widget

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

Intent ACTION_OPEN_DOCUMENT:浏览多种MIME类型

我的目的是让用户选择图像:

 fun launchChooseFileIntent(callerFragment: BaseFragment, REQUEST_CODE: Int) {
    val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
        addCategory(Intent.CATEGORY_OPENABLE)
        type = "image/*,"
    }

    startActivityForResult(intent, REQUEST_CODE)
}
Run Code Online (Sandbox Code Playgroud)

现在我需要用户可以选择图像和 pdf 文档。我尝试更改类型字符串,例如

type = "image/*,application/pdf"
Run Code Online (Sandbox Code Playgroud)

或者喜欢

type = "image/*|application/pdf"
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

我也尝试添加额外的意图,例如

putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("image/*", "application/pdf"))
Run Code Online (Sandbox Code Playgroud)

但应用程序崩溃了。

我该如何解决它?

android android-intent mime-types

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

tolower()函数问题

这是我的示例代码:

#include<stdio.h>
#include<string.h>
#include<ctype.h>

void convert(char *a, char *b) {
    int i;
    for(i=0; i<strlen(a); i++) {
        b[i]=tolower(a[i]);
    }
}

int main() {
    char a[20], b[20];

    fgets(a, sizeof(a), stdin);
    convert(a, b);
    printf("%s\n", b);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但有时convert()函数还会转换一个char而不是strlen(a)(它是一个随机字符),例如这是一个输出:

ASDSA
asdsa
%
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

c unix tolower

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

信号处理程序sa_sigaction参数

我有

struct sigaction pipe_act;
pipe_act.sa_flags = SA_SIGINFO;
pipe_act.sa_sigaction = sigpipehandler
sigaction(SIGPIPE, &pipe_act, NULL);
Run Code Online (Sandbox Code Playgroud)

当我尝试编写sigpipeHandler时,gcc告诉我它需要三个args.第二个args是好的,它的siginfo_t结构包含有关signal的信息,bue第一个和第三个(int和void变量),它们是什么?

c unix signals

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

JTable单击了行侦听器

我有一个JTable包含字符串矩阵的动态,我需要编写一个监听器,当双击一行时,读取一个特定的列并对其进行一些计算.我应该使用哪种听众?

java swing awt jtable listener

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

Java jdbc float 和 postgres 类型映射

Float java 类型和 postgresql 类型之间的映射是什么?我尝试过使用数字,但我事先不知道精度有多大

postgresql types jdbc

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

ImageView:在按下和发布时更改图像

我会在按下时更改imageView图片,并在压力释放时再次更改.ImageView包含一个按钮的图片,当按下时,我会通过更改图像向用户提供反馈(例如,当他按下正常按钮时).这是我的代码:

final ImageView imageView = (ImageView) findViewById(R.id.imageView1);
imageView.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        Log.i("IMAGE", "motion event: " + event.toString());
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN: {
            imageView.setImageResource(R.drawable.button_hover);
        }
        case MotionEvent.ACTION_UP: {
            imageView.setImageResource(R.drawable.button);
        }
        }
        return false;
    }
    });
Run Code Online (Sandbox Code Playgroud)

这是xml

 <ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="std_button"
    android:src="@drawable/button" />
Run Code Online (Sandbox Code Playgroud)

但它不起作用.如果我只使用ACTION_DOWN事件,图像改变我想要,有什么问题?

android android-imageview

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

Edmodo android图像裁剪器,修复宽高比

我在android lollipop上使用edmodo/cropper库时遇到了一些问题.我的应用程序应拍摄一些照片,每张照片拍完后,用户应剪裁正方形图像.这是我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.example.newapicamera.AutoFitTextureView
    android:id="@+id/texture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/footer" />

<com.edmodo.cropper.CropImageView
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:id="@+id/CropImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/footer"
    android:visibility="invisible" />

<ImageView
    android:id="@+id/footer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:src="@drawable/footer" />

<TextView
    android:id="@+id/current_picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:textColor="#FFFFFF"
    android:textSize="30sp" />
Run Code Online (Sandbox Code Playgroud)

这就是我拍摄照片后如何启动作物库的方法;

crop_view.setImageBitmap(bitmap);
mCameraDevice.close();
mTextureView.setVisibility(View.INVISIBLE);
crop_view.setVisibility(View.VISIBLE);
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int dpWidth = displayMetrics.widthPixels;
crop_view.setFixedAspectRatio(true);
crop_view.setAspectRatio(dpWidth, dpWidth);
Run Code Online (Sandbox Code Playgroud)

我有后续问题:

  • 使用此代码,裁剪是一个条纹高的屏幕
  • 如果我删除固定宽高比,我会忽略宽高比,并获得矩形裁剪.那么,我怎样才能将庄稼逼到广场?

android crop

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

React Native TextInput:占位符和 detx 填充

我有一个带有圆角的 TextInput :

<TextInput
    style={{
        backgroundColor : '#FFFFFF',
        borderRadius : 30,
        marginLeft : 8,
        marginRight : 8,
        marginTop : 10
    }}
    placeholder = 'A placeholder'
/>
Run Code Online (Sandbox Code Playgroud)

但我想为占位符(以及将包含在 TextInput 中的文本)提供一些左侧填充,因为现在文本太靠近左侧 TextInput 边框。我该怎么做?

textinput react-native react-native-textinput

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

具有自定义布局的工具栏:左侧空白

我正在尝试向我的应用程序添加自定义工具栏。这是布局:

<androidx.appcompat.widget.Toolbar
        android:id="@+id/actionbar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorAccent"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorPrimary"
            android:orientation="horizontal">

            <ImageButton
                android:id="@+id/back_button"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:background="@drawable/ic_arrow_back_black_24dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="LOGO"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.appcompat.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

但是工具栏左边框和 ConstraintLayout 开始边框之间有一种间隙(粉红色的间隙)在此输入图像描述

我怎样才能删除它?

android android-actionbar android-toolbar androidx

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