2013-12-03 4 views
0

Я решаю проблему с изображением и текстом в одном прокрутке. Основная проблема заключается в том, что я получаю разную высоту изображения со стороны сервера. Но место с изображением должно быть одинаковым. Теперь высота места изображения динамична. Текст должен быть прокручиваемым с изображением.Android Scroll view Изображение и текст

Есть ли возможность сделать изображение высотой статическим?

Спасибо!

enter image description here

EDIT

<?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" > 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:id="@+id/article_gallery" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="4" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal" > 

       <ImageView 
        android:id="@+id/article_image_back" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:src="@drawable/sipka_l" /> 

       <ImageView 
        android:id="@+id/article_image" 
        android:layout_width="0dip" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:layout_weight="1" /> 

       <ImageView 
        android:id="@+id/article_image_next" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:src="@drawable/sipka_p" /> 
      </LinearLayout> 

      <TextView 
       android:id="@+id/image_desc" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:background="@color/tran_dark_gray" 
       android:gravity="center" 
       android:padding="@dimen/size_8" 
       android:textAppearance="@style/xsmallLight" /> 
     </RelativeLayout> 

     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="6" 
      android:background="@color/opaq_light" 
      android:orientation="horizontal" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:padding="@dimen/size_16" > 

       <TextView 
        android:id="@+id/article_title" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:paddingBottom="@dimen/size_12" 
        android:textAppearance="@style/normalBold" /> 

       <TextView 
        android:id="@+id/article_body" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textAppearance="@style/xsmall" /> 
      </LinearLayout> 
     </ScrollView> 
    </LinearLayout> 
</FrameLayout> 

ответ

0

Если вы объявляете ImageView с фиксированной шириной и высотой он будет оставаться статичным все время.

Попробуйте что-то вроде:

<ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
/> 

Put это ImageView внутри ScrollView и, конечно, положить TextView внутри же ScrollView.

+0

Спасибо ответ. Но для каждого разрешения экрана будет одинаковая высота, не будет? Есть ли возможность определить его с коэффициентом отношения, например, 30% всего экрана, а не для полного просмотра прокрутки? Потому что изображение 50dp будет небольшим с высоким разрешением. –

0

вы можете использовать макеты для вашего линейного выключения. Установите ширину в 0 и пусть вес определит фактический размер. Устанавливая вес до 0,33 каждый, вы получаете каждое изображение на 1/3 экрана. Или вы можете установить один на 0.5, а остальные на 0.25 каждый или что-то, что имеет смысл для вашего приложения.

Установите 3 изображения, как:

 <ImageView 
      android:id="@+id/article_image_back" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.33" 
      android:layout_gravity="center_vertical" 
      android:src="@drawable/sipka_l" />