0
centerInside
centerInside不结垢可绘制到的ImageView
缩放图像的描述均匀(保持图像的纵横比),以使图像的两个尺寸(宽度和高度)将等于或小于视图的相应维度(减去填充)。
我想这个描述意味着图像应该缩放到最接近它的视图容器中的边缘。
在我的资产文件夹此一点红方似乎并没有被缩放
这里是我的main_activity.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ImageView
android:id="@+id/redSquare"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:background="#00ffff"
/>
</android.support.design.widget.CoordinatorLayout>
这里我设置绘制的图像视图
ImageView redSqaure;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main_activity);
//...
try {
InputStream ims = getAssets().open("redSquare.png");
Drawable d = Drawable.createFromStream(ims, null);
// Setting the drawable to image view
redSqaure.setImageDrawable(d);
ims .close();
} catch(IOException ex) {
}
}
任何帮助?谢谢。
属性您共享似乎并不具备,我想 –
@the_prole我编辑的anwser –
影响的XML看起来像它可能正在工作,唯一的问题是,应用程序栏已经覆盖图像视图 –