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看起來像它可能正在工作,唯一的問題是,應用程序欄已經覆蓋圖像視圖 –