안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요..
ImageView url 여백 생기는 문제로 질문을 했다가 해결은 잘 됐으나.. 다른 문제가 생겨 또 질문 합니다^^
안드로이드 2.3에서는 아래 프로그램으로 잘 됩니다. 웹서버에서 파일을 불러와서 잘 띠워 줍니다.
그런데 안드로이드 4.0이상에서는 화면에 보여주질 못하네요.
안드로이드 3.0은 테스트를 안해봤습니다. ^^
버전차이에서 생기는 프로그램 문젠가요??
==================================================Manifest===================================================
<uses-permission android:name="android.permission.INTERNET"/>
=================================================== xml ======================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/back" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/title" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/information_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:scaleType="fitStart" ></ImageView>
</ScrollView>
</LinearLayout>
====================================================== java =====================================================
ImageView information_view = (ImageView)findViewById(R.id.information_view);
try {
URL url = new URL("http://127.0.0.1/information.png);
URLConnection conn = url.openConnection();
conn.connect();
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
information_view.setImageBitmap(bm);
} catch (Exception e) {
}
===============================================================================================================




이미지 가져오는 부분을 AsyncTask 로 돌려 보시고 안되면..
이미지뷰대신 웹뷰를 써보세요~