2011-11-04 4 views
0

У меня есть набор из 10 изображений, которые нужно установить в верхней части экрана. В портретном режиме он идеален в соответствии с требованием. Но когда я поворачиваю ориентацию экрана к пейзажу, количество изображений остается таким же, но ширина не подходит для макета. Я имею в виду, что набор из 10 представлений изображений заполняет только 50% экрана.Набор изображений, не подходящих для ландшафтного режима

Я пытался по-разному, но все-таки я не могу сделать это для ландшафта

Вот мой XML сказать main.xml

<RelativeLayout android:id="@+id/relativeLayout1" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<LinearLayout 
android:layout_alignParentTop="true" 
android:id="@+id/progresslayout" 
android:orientation="horizontal" 
android:layout_width="wrap_content" android:layout_height="wrap_content"> 

<ImageView android:src="@drawable/progressgreen" android:id="@+id/pb1" 
    android:layout_height="wrap_content" android:layout_width="wrap_content" 
    android:layout_alignParentLeft="true"></ImageView> 


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

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

<ImageView android:src="@drawable/progressgreen" android:id="@+id/pb4" 
    android:layout_toRightOf="@+id/pb3" android:layout_height="wrap_content" 
    android:layout_width="wrap_content"></ImageView> 

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

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

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

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

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

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

    </LinearLayout> 

    </RelativeLayout> 

Я попытался дать андроида: layout_weight =»" свойство также, но все еще бесполезно. И интересно, что я заметил здесь вместо того, чтобы увидеть увеличенное изображение, если я пытаюсь то же самое с некоторой кнопки или редактирования текста, поданного, он прекрасно работает как в портретной и альбомной

+0

ваша ширина LinearLayout и высота должна быть как андроида: layout_width = "fill_parent" андроид: layout_height = "fill_parent" –

+0

@Padma Кумар, я пытался что – tejas

ответ

1

Там вы идете

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/relativeLayout1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<LinearLayout 
    android:id="@+id/progresslayout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/pb1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb3" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb4" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb5" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb6" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb7" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb8" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb9" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 

    <ImageView 
     android:id="@+id/pb10" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:src="@drawable/ic_launcher" > 
    </ImageView> 
</LinearLayout> 

Не забудьте заменить android:src="@drawable/ic_launcher" с вашего ресурса изображения. Это создаст десять изображений, расположенных на экране, между ними.

Если вы не хотите пространства между изображениями, используйте для каждого изображения свойство android:scaleType="fitXY". Удачи.

+0

я попробовал это. В этом случае изображения подходят, но изображение не видно. Если я даю вес как 0 или 0,2, вместо 1, изображения появляются, но не подходят для макета. – tejas

+0

У вас есть другие изображения? Я проверил перед публикацией здесь. – PH7

+0

Да, я пробовал с другими изображениями. Это происходит только для изображений, для полей, таких как редактирование текста или кнопки, это работает – tejas

0

В теге LinearLayout удалить

андроида : ориентация = "горизонтальные"

атрибута и изменить

Android: layout_width = "wrap_content"

Попробуйте

0

Попробуйте использовать android:layout_weight="1" и android:layout_width="fill_parent". Это позволит убедиться, что все объекты имеют общую ширину макета, и каждый занимает одно и то же пространство.

0

Try,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/relativeLayout1" 
android:weightSum="2" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<LinearLayout 
    android:id="@+id/progresslayout" 
    android:layout_weight="1" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:weightSum="10" 
    android:orientation="horizontal" > 
// Your ImageViews Here 
    <ImageView 
    android:id="@+id/pb10" 
    android:layout_weight="1" 
    android:layout_width="0dp" 
    android:layout_height="fill_parent" 
    android:src="@drawable/image1" > 
    </ImageView> 

</LinearLayout> 
</LinearLayout> 
+0

родительский внутренний линейный макет должен относиться только к относительной макете – tejas

+0

могу я знать, почему это необходимо? и вы говорите о макете, содержащем 10 изображений? – MKJParekh

+0

Нет, я говорю о самом внешнем линейном макете, который содержит внутренний макет. Это всего лишь часть всего макета. Многие другие вещи связаны с внешней относительной компоновкой, поэтому необходимо, чтобы – tejas

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