2017-02-28 78 views
0

我有應該在佈局背景(全屏)上安裝的jpeg圖像。我想我應該測量設備屏幕的高度和寬度,並放大我的圖片。我在嘗試使用xml中的中心裁剪圖片時也遇到了onClick凍結。任何建議將不勝感激。安裝背景圖像的最佳做法

這裏是我的佈局:

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:theme="@style/AppTheme.Dark" 
    android:background="#1B1B21"> 

    <ImageView 
     android:id="@+id/above_mountains" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/above_mountains"/> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:paddingTop="48dp" 
     android:paddingRight="16dp" 
     android:paddingLeft="16dp" 
     android:paddingBottom="16dp"> 

    ...ACTUAL LAYOUT HERE... 

</LinearLayout> 

</FrameLayout> 
+0

你試過'機器人:背景= 「@繪製/ your_image.jpg」'你的佈局? – miljon

+0

所以你想知道'如何在應用程序的背景上安裝jpeg'和'如何在嘗試裁剪圖片時防止點擊凍結'?如果是的話,你需要發佈你的代碼第二個。問題不清楚順便說一句,你需要澄清它。 –

+0

我添加了我的佈局。我需要縮放與裁剪和不凍結。 – Daimonium

回答

0

我建議你使用Glide圖像加載庫

Glide.with(context).load(R.drawable.above_mountains).centerCrop().into(imageView); 
+0

比畢加索好嗎?中心作物不是一個好的決定。我需要使用裁剪進行縮放。 – Daimonium

+0

是的,請查看[documentation](https://github.com/bumptech/glide)。 'CenterCrop'自動縮放作物 –

+0

謝謝。聽起來很甜美。我會試試看。如果一切都會好的,我會接受這個答案。 – Daimonium