ImageView属性以及导入问题

 xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
显示模式
        android:scaleType="centerInside"
导入图片目录
        android:src="@drawable/img"></ImageView>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
设置图片显示最大高宽,以最长为限制,其端等比缩放
        android:maxHeight="200dp"
        android:maxWidth="200dp"
        android:adjustViewBounds="true"

        android:scaleType="centerInside"
        android:src="@drawable/img"></ImageView>


</LinearLayout>

 导入图片问题

在app下的android项导入 

 

aaptOptions.cruncherEnabled = false;
  aaptOptions.useNewCruncher = false;
plugins {
    id 'com.android.application'
}

android {
//这个位置
    aaptOptions.cruncherEnabled = false;
    aaptOptions.useNewCruncher = false;

    compileSdk 31

    defaultConfig {
        applicationId "com.example.android_01"
        minSdk 24
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

已久 冒红的话

图片命名问题(以数字开头)

图片格式不支持

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值