2013-01-16 5 views
0

고정 이미지 및 스크롤 가능한 텍스트 뷰가있는 레이아웃이 필요합니다. 문제는 텍스트가 증가하면 이미지 뷰가 더 작아지고 그 반대의 경우도 마찬가지입니다. 나는 이미지의 크기를 고정시키고 싶다.수정 이미지 뷰 및 스크롤 가능한 텍스트 뷰

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="#000" 
     android:src="@drawable/luna" /> 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

<TextView 
    android:text="test test test test" 
    android:textSize="15pt" 
    android:background="#000000" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 

</ScrollView> 
</LinearLayout> 

E/AndroidRuntime( 729): FATAL EXCEPTION: main 
E/AndroidRuntime( 729): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.luna/com.example.luna.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown> 
E/AndroidRuntime( 729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 
E/AndroidRuntime( 729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
E/AndroidRuntime( 729): at android.app.ActivityThread.access$600(ActivityThread.java:130) 
E/AndroidRuntime( 729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
E/AndroidRuntime( 729): at android.os.Handler.dispatchMessage(Handler.java:99) 
E/AndroidRuntime( 729): at android.os.Looper.loop(Looper.java:137) 
E/AndroidRuntime( 729): at android.app.ActivityThread.main(ActivityThread.java:4745) 
E/AndroidRuntime( 729): at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime( 729): at java.lang.reflect.Method.invoke(Method.java:511) 
E/AndroidRuntime( 729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
E/AndroidRuntime( 729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
E/AndroidRuntime( 729): at dalvik.system.NativeStart.main(Native Method) 
E/AndroidRuntime( 729): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown> 
E/AndroidRuntime( 729): at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
E/AndroidRuntime( 729): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
E/AndroidRuntime( 729): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256) 
E/AndroidRuntime( 729): at android.app.Activity.setContentView(Activity.java:1867) 
E/AndroidRuntime( 729): at com.example.luna.MainActivity.onCreate(MainActivity.java:21) 
E/AndroidRuntime( 729): at android.app.Activity.performCreate(Activity.java:5008) 
E/AndroidRuntime( 729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
E/AndroidRuntime( 729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
E/AndroidRuntime( 729): ... 11 more 
E/AndroidRuntime( 729): Caused by: java.lang.reflect.InvocationTargetException 
E/AndroidRuntime( 729): at java.lang.reflect.Constructor.constructNative(Native Method) 
E/AndroidRuntime( 729): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
E/AndroidRuntime( 729): at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
E/AndroidRuntime( 729): ... 24 more 
E/AndroidRuntime( 729): Caused by: java.lang.OutOfMemoryError 
E/AndroidRuntime( 729): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
E/AndroidRuntime( 729): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500) 
E/AndroidRuntime( 729): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353) 
E/AndroidRuntime( 729): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781) 
E/AndroidRuntime( 729): at android.content.res.Resources.loadDrawable(Resources.java:1930) 
E/AndroidRuntime( 729): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
E/AndroidRuntime( 729): at android.widget.ImageView.<init>(ImageView.java:120) 
E/AndroidRuntime( 729): at android.widget.ImageView.<init>(ImageView.java:110) 
E/AndroidRuntime( 729): ... 27 more 
W/ActivityManager( 150): Force finishing activity com.example.luna/.MainActivity 
W/WindowManager( 150): Failure taking screenshot for (164x246) to layer 21010 
I/Choreographer( 150): Skipped 104 frames! The application may be doing too much work on its main thread. 
W/ActivityManager( 150): Activity pause timeout for ActivityRecord{412421f0 com.example.luna/.MainActivity} 
I/Choreographer( 150): Skipped 31 frames! The application may be doing too much work on its main thread. 
I/Choreographer( 262): Skipped 79 frames! The application may be doing too much work on its main thread. 
I/Choreographer( 150): Skipped 43 frames! The application may be doing too much work on its main thread. 
I/Choreographer( 150): Skipped 31 frames! The application may be doing too much work on its main thread. 
I/Choreographer( 150): Skipped 35 frames! The application may be doing too much work on its main thread. 
I/ActivityManager( 150): No longer want com.android.contacts (pid 371): hidden #16 
W/ActivityManager( 150): Activity destroy timeout for ActivityRecord{412421f0 com.example.luna/.MainActivity} 
+0

원인 : java.lang.OutOfMemoryError 문제가 현재 레이아웃에 없습니다. 덕분에 – AMerle

답변

1

당신이 당신의 scrollviewandroid:layout_weight="1"android:layout_height="0dp" 시도 (그리고 imageview/textview에서 제거) 했습니까?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/luna" /> 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

<TextView 
    android:text="test test test test" 
    android:textSize="15pt" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 

</ScrollView> 
</LinearLayout> 
+0

. 코드를 사용하면 텍스트가 표시되지 않습니다. –

+0

@PolHallen이 테스트 해봤는데 잘 작동합니다. 'imageview'와'textview'에서'layout_weight'를 제거 했습니까? – AMerle

+0

활동을 시작할 수 없습니다. ComponentInfo {com.example.luna/com.example.luna.MainActivity} : android.view.InflateException : 이진 XML 파일 줄 8 번 : 오류가 발생하는 클래스 E/AndroidRuntime (898) : \t android .app.ActivityThread.performLaunchActivity (ActivityThread.java:2180) E/AndroidRuntime (898)에서 \t android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2230) E/AndroidRuntime (898)에서 \t android.app .ActivityThread.access $ 600 (ActivityThread.java:141) E/AndroidRuntime (898) : \t android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1234) –

관련 문제