小编Kuy*_*uya的帖子

Android中的ImageButton

任何人都可以告诉我如何调整imageButton的大小以使图像精确拟合.这是我尝试的代码,但图像放置在我定位的位置, imageButton但我无法减小imageButton的大小,请帮我纠正这个问题...我试过的代码是......

<ImageButton>
android:id="@+id/Button01"
android:scaleType="fitXY" // i have tried all the values for this attr
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="false"
android:paddingLeft="10dp"
android:src="@drawable/eye"> // this is the image(eye)
</ImageButton>
Run Code Online (Sandbox Code Playgroud)

android imagebutton

24
推荐指数
3
解决办法
10万
查看次数

如何使用docker Registry API v2将映像推送到docker注册表

我正在编写一个docker注册表api包装器,用于从一个私有注册表中提取图像并将它们推送到另一个私有注册表.

首先根据文档我需要拉出清单和图层image:tag.在 Puling An Image之后,我已经成功下载了特定image:tag和清单的所有图层.

下面推的图像,我遵循的步骤:

  1. POST /v2/<name>/blobs/uploads/(获取UUID即Location标题)
  2. HEAD /v2/<name>/blobs/<digest> (检查注册表中是否已存在)
  3. PUT /v2/<name>/blobs/uploads/<uuid>?digest=<digest>(Monolithic Upload)

对我来说不清楚的是:

  1. UUID我推送的每个单独层是唯一的还是对所有层重用的(例如,我是否需要为每个层运行一个新的POST,UUID然后在尝试上传之前获取新的?).
  2. 完成上传部分指示

要使上传被视为完成,客户端必须在上传端点上使用摘要参数提交PUT请求

但是,正如我所提到的,我正在使用单片上传,它使用的是PUT与完成上传部分中显示的相同的请求.所以通过单片上传,我还可以同时完成上传吗?

问题

  1. 当我完成上述所有步骤时,我BLOB_UNKNOWN 在上传摘要时收到错误,例如

    {"errors:"[{"code":"BLOB_UNKNOWN","message":"blob unknown to registry","detail":{"digest":}},...]}

根据文档,在推送清单时会产生此错误,并且清单中的其中一个层未知:

如果注册表未知一个或多个图层,则返回BLOB_UNKNOWN错误.错误响应的详细信息字段将具有标识丢失的blob的摘要字段.每个未知blob都会返回一个错误.响应格式如下:

令我困惑的是

  1. 我正在推送一个摘要(也就是一个层)而不是清单,为什么这个错误会返回?
  2. 我希望blob是未知的,因为我正在将新图像推入注册表

现在我将使用docker客户端,但是我没有在线找到任何包装器示例,看看它是如何被拉出来的.据推测,我错过了一些逻辑或误解了文档,但我不确定我哪里出错了?

docker docker-registry docker-api

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

如何在PrestaShop结账时允许编辑属性,例如颜色,尺寸?

我正在使用PrestaShop创建一个电子商务商店.

当用户在结帐时:

在此输入图像描述

是否有任何模块/修改可以实现允许用户选择另一个属性,例如结账时的颜色,大小?

html javascript php prestashop

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

Android 应用程序图标随运行时变化

在我的应用程序中,我想为应用程序显示不同的图标。更改应根据场景进行。例如,它将标记任务完成的剩余天数。在 android 菜单上,此图标将显示剩余天数。如果有人对此有任何想法,我将不胜感激。谢谢。

icons android runtime android-image android-menu

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

如何减少React-Native android应用程序大小

对于我的本机安卓应用程序,我写的代码大小只有12KB

但是生成的包大小为7.9MB.我怎么能减少这一点.

根据本地的反应文档,我已经在文件中找到了proguard app_root/android/app/proguard-rules.pro但是大小并没有减少

...
android {
    ...
    buildTypes {
        release {
            ...
            minifyEnabled true
        }
    }
}
...
Run Code Online (Sandbox Code Playgroud)

有没有可用的解决方案?

android android-gradle-plugin react-native react-native-android

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

如何修复“Android SDK 构建工具版本 (27.0.3) 被忽略...”

我正在flutter上做一个应用程序。我连接了map_view: ^0.0.14在地图上绘制道路,但出现以下错误:

  • 运行 Gradle 时出错:ProcessException:进程“C:\Users\admin\AndroidStudioProjects\advertise\android\gradlew.bat”异常退出:

配置项目 :app registerResGenerateTask 已弃用,使用 registerGenerateResFolders(FileCollection) registerResGenerateTask 已弃用,使用 registerGenerateResFolders(FileCollection) registerResGenerateTask 已弃用,使用 registerGenerateResFolders(FileCollection)

配置项目 :map_view 警告:指定的 Android SDK 构建工具版本 (27.0.3) 将被忽略,因为它低于 Android Gradle 插件 3.2.1 支持的最低版本 (28.0.3)。将使用 Android SDK 构建工具 28.0.3。要抑制此警告,请从 build.gradle 文件中删除“buildToolsVersion '27.0.3'”,因为每个版本的 Android Gradle 插件现在都有默认版本的构建工具。****************************************************** ****** 警告:如果此版本的 firebase_auth 或其依赖项与 AndroidX 不兼容,它将破坏您的 Android 构建。有关该问题及其解决方法的更多信息,请参阅 goo.gl/CP92wY。对于所有 Android 构建失败都会打印此警告。错误的真正根本原因可能是无关的。****************************************************** ******

失败:构建失败并出现异常。

  • 出了什么问题:Android Gradle 插件仅支持 Kotlin Gradle 插件版本 1.2.51 及更高版本。项目“map_view”使用版本 1.2.50。

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • 在help.grade.org获取更多帮助

2秒内构建失败命令:C:\Users\admin\AndroidStudioProjects\advertise\android\gradlew.bat app:properties

已完成,但出现错误:请检查 android/ 文件夹中的 Gradle 项目设置。 …

android build.gradle android-gradle-plugin flutter

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

Android Studio 错误:无法从“file:/C:/Users/~/gradle/wrapper/”安装 Gradle 发行版

我是一个完全的菜鸟,需要一些帮助。我该如何纠正这个问题?多谢!!哪里错了?

我的档案

gradle-wrapper.properties

 #Fri Jul 19 12:04:39 BST 2019
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=
      https\://services.gradle.org/distributions/gradle-5.1.1-all.zip= 
Run Code Online (Sandbox Code Playgroud)

build.gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.example.a7700teste"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 5
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.1.1'
    implementation 'com.android.support:design:28.1.1'
    implementation 'com.android.support:exifinterface:28.1.1'
    implementation 'com.android.support.constraint:constraint-layout:3.0.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation …
Run Code Online (Sandbox Code Playgroud)

android-studio android-gradle-plugin

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

当应用程序在后台/未运行时如何设置自定义通知声音?

当应用程序位于前台时,可以通过在 resources/raw 文件夹中提供声音文件来播放自定义通知声音,然后在对通知做出反应时,执行以下操作:

Android.Net.Uri notification = Android.Net.Uri.Parse("android.resource://" + Application.Context.PackageName + "/raw/thesoundfile");                       
Ringtone rt = RingtoneManager.GetRingtone(a, notification);
rt.Play();
Run Code Online (Sandbox Code Playgroud)

然而。显然,当应用程序在后台时,这不会被执行,并且当通知到达时操作系统仍然会播放(默认)通知声音。

如何以编程方式设置此“背景”通知声音,使其与前台播放的自定义声音相同?

我查看了用于关闭这篇文章的“重复”问题。这个问题是在 7 年前提出的,当时 Android 还处于 Jelly Bean 版本(4.1 - 4.3.1)。七年前有效的方法在今天并不总是有效。该答案已过时,并且不适用于 Oreo (10) 版本。

notifications android android-notifications

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

java.lang.ClassCastException:android.widget.RelativeLayout

我开发了一个简单的listview应用程序,它显示了listview,但是当我选择单个列表视图时,它会出现以下错误.

这是我的单个列表项xml文件.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<TextView android:id="@+id/product_label"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="25dip"
        android:textStyle="bold"
        android:padding="10dip"
        android:textColor="#ffffff"/>   
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的MainActivity.java文件

import java.util.List;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.Toast;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import android.widget.ListView;
import android.widget.TextView;

public class MainActivity extends ListActivity implements FetchDataListener{
private ProgressDialog dialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);        
    setContentView(R.layout.activity_main);        
    initView(); 

    ListView lv = getListView();

    // listening to single list item on click
    lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, …
Run Code Online (Sandbox Code Playgroud)

java android listview classcastexception

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

如何访问Android Q中的所有图片?

我想制作一个像相册一样的库并将其改编成Android Q

由于范围存储,MediaStore.Images.ImageColumns.DATA已弃用;

我们不能直接通过路径读取文件 /storage/emulated/0/DCIM/xxx.png

MediaStore.Images.ImageColumns 没有像 URI 这样的值,所以我无法通过 ContentProvider 获取图片。

这种方式我们只能打开一张图片(下面的代码),在回调中接收到一个URI;

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones).
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Filter to show only text files.
intent.setType("image/*");
Run Code Online (Sandbox Code Playgroud)

但是我想访问所有图片,那么,如何在 Android Q 中扫描所有图片?

android mediastore android-10.0

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

如何从其他数组的数字位置获取数组?

我有一个数组A = [1,3]- 它存储来自另一个数组的正确答案的位置B = ["answer1","answer2","answer3","answer4"]。我需要得到一个数组C,它将由正确的答案组成,就像这样["answer1","answer3"]

示例:如果数组A由 1 个元素组成(例如A = [2]),则数组C应该类似于C = ["answer2"]

indexOf()当我有一个由 1 个元素组成的数组A时,我可以用 来解决这个问题。但是当有 2 个或更多元素时,我会卡住

javascript

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

向Android Studio添加活动

这是我的第一个Android应用程序.我正在尝试做一些应该相对简单的事情,但我似乎无法让它发挥作用.

AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.project1.project1">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/icon_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/icon_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".LoginActivity">
        <intent-filter>
            <action android:name="android.intent.action.DEFAULT" />
        </intent-filter>
    </activity>
</application>

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

login_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/loginSignup1Background"
tools:context=".LoginActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:orientation="vertical">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginLeft="16dp"
        android:text="@string/login_title"
        android:textAppearance="@style/TextAppearance.AppCompat.Headline" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:contentDescription="Login Icon" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-studio

-4
推荐指数
1
解决办法
170
查看次数