2010-11-09 2 views
0

Это мой main.xml, который я использую, и два изображения в myImage_Main и myImage_Main2 испорчены.
Есть ли способ установить android: layout_width в размер растрового изображения? или я просто устанавливаю его на 500 пикселей, что касается размера экрана?Android Проблема с scrollviews и изменением размера

Пример того, что я хочу:

 
Scroll view ------------------------------- 
| 
|    Image 1 Full Sized on Screen 
| 
| 
|    Bottom of screen 
___________________________________________ 
|    Not yet on screen, but 
|   Scroll down to see Image 2 | 
| 
| 
| 
|_____________________________________________| 
<?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" 
    > 


    <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_gravity="top" 
     > 
     <Button android:id="@+id/myButton_Search" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_search" 
    android:layout_gravity="top" 
    /> 
    <Button android:id="@+id/myButton_Save" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_save" 
    android:layout_gravity="top" 
    /> 
    </LinearLayout> 

    <EditText 
    android:id="@+id/myEdittext" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    /> 
<ScrollView android:id="@+id/ScrollView01" 
android:layout_width= **Right here I want to get the size of the image i use as the width** 
android:layout_height=**Right here I want to get the size of the image i use as the height** 
android:fillViewport="true" 
android:scrollY="100px" 
> 
<LinearLayout android:id="@+id/LinearLayout02" 
android:layout_width=**Right here I want to get the size of the image i use as the width** 
android:layout_height=**Right here I want to get the size of the image i use as the height** 
android:orientation="vertical"> 
    <ImageView android:id="@+id/myImage_Main" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scaleType="fitCenter" 
    /> 
    <ImageView android:id="@+id/myImage_Main2" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scaleType="fitCenter" 
    /> 
    </LinearLayout> 
    </ScrollView> 
</LinearLayout> 
+0

Сколько места осталось для вашего ScrollView? И попробуйте ли вы это: http://developer.android.com/reference/android/widget/ImageView.html#attr_android:scaleType? – xandy

ответ

1

Просто используйте wrap_content для всех из них. Когда макет раздувается в setContentView(R.layout.your_layout), он определит точное количество ширины, необходимое для отображения всех его дочерних видов. Однако вам нужно установить scaleType="none". Я не совсем уверен, что вы пытаетесь сделать, поэтому, если я не понимаю вопрос, пожалуйста, уточните.

Смежные вопросы