2013-05-29 6 views
0

Android 응용 프로그램을 개발 중이며 전체 화면으로 그림을 표시하려고합니다. https://github.com/jasonpolites/gesture-imageview그림을 다운로드하고 응용 프로그램에서 파일을 임시 저장하는 방법

활동의 interfice의 XML은 이것이다 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:gesture-image="http://schemas.polites.com/android" 
android:id="@+id/layout" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:background="#000000"> 
    <com.polites.android.GestureImageView 
    android:id="@+id/image" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scaleType="centerInside" 
    gesture-image:min-scale="0.75" 
    gesture-image:max-scale="10.0" 
    android:src="@drawable/image"/> 
</LinearLayout> 

하지만 난이/드로어 블 폴더의 사진을 사용하지 않으려는이를 위해

나는이 exemple의 코드를 사용 , 나는 URL의 img 다운로드를 사용하고 싶다.

어떻게 그림을 다운로드하거나, 메모리 또는 일부 폴더에 넣을 수 없으며 xml 파일에이 경로를 넣을 수 있습니까?

도움 주셔서 감사합니다.

답변

0

당신은 그렇게 할 수 없습니다. APK의 res 디렉토리 파일은 READ ONLY입니다. 이미지 URL을 잡고 파일로 내부 저장소에 저장 한 다음 나중에 렌더링 할 수 있습니다. 원하는 특정 파일 경로에 이미지를 저장할 수 있습니다. 그리고 이미지 뷰에서 드로어 블 이미지를 대체 할 프로그래밍 방식으로 보여줍니다. 이미 이미지를 다운로드하는 경우

0

코드 시도 :

GestureImageView image = (GestureImageView)findViewById(R.id.image); 
Bitmap bmp = BitmapFactory.decodeFile(imageFilePath); 
image.setImageBitmap(bmp); 

을 또는 다음과 같은 시도 할 수 있습니다 :

GestureImageView image = (GestureImageView)findViewById(R.id.image); 
InputStrean is = new URL("http://.../.../xxx.jpg").openConnection().getInputStream(); 
Bitmap bmp = BitmapFactory.decodeStream(is); 
image.setImageBitmap(bmp); 
+0

감사합니다, 나는 클래스 GestureImageView이 코드를 시도하고 작동하지 않습니다 정확하게,하지만 하나의 ImageView "전체 부모"와 작품이 코드를 사용할 수있는, 나는 단지 여백에 문제가 있습니다. – user2423292

관련 문제