2017-08-08 65 views
0

我想補充一個背景圖片,黑色ImageView的同時恢復活動或軟鍵盤更改

下面是XML代碼

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:id="@+id/chatroompage" 
     android:background="#EEEEEE" 
     android:layout_height="match_parent"> 
     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/background" 
      android:scaleType="centerCrop"/> 
    </RelativeLayout> 

我用滑翔加載圖像。

Glide.with(this).load(imageuri).into(background); 

在第一次加載時工作正常。但是當我使用鍵盤或恢復活動時,圖像變黑。

thanx的幫助。

+0

從移除背景'RelativeLayout'另外使用佔位符圖像而被加載的圖像。 –

+0

我需要RelativeLayout背景,使用圖像背景是可選的。如果設置有圖像背景,然後我添加代碼的圖像背景 – Kim

+0

但我會嘗試這樣做, – Kim

回答

0

把這個代碼:

android:windowSoftInputMode="stateVisible|adjustPan" 

條目中<Activity >標籤中manifest文件。

把你的滑翔集圖像代碼在此方法中:

 @Override 
    protected void onResume() { 
     super.onResume(); 
     Glide.with(this).load(imageuri).into(background) 
     .load(getItem(position)) 
     .asBitmap() 
     .imageDecoder(new StreamBitmapDecoder(imageView.getContext(), 
     DecodeFormat.PREFER_ARGB_8888)) 
     .override(400, 300) 
     .fitCenter() 
     .skipMemoryCache(true); 
    } 

您注意到,我們稱之爲.skipMemoryCache(真)明確告訴滑翔跳過內存緩存。

參考文獻:

https://github.com/bumptech/glide/issues/738

https://github.com/bumptech/glide/issues/527

https://github.com/bumptech/glide/issues/673

+0

它在某種程度上解決了鍵盤問題,但是當我在回家按鈕點擊並回到活動,同樣黑屏 – Kim

+0

你在活動或片段使用滑行? @NoobCoder –

+0

在活動中。 – Kim