user997593
user997593

Reputation: 433

android, imageviews inside linear layout don't fit the screen size

I was wondering how to make the four images inside my LinearLayout look as big as possible depending on the screen. When I install the widget in my phone, it always fits only 50% of the screen. Here comes the xml. Any hints?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|clip_horizontal"
android:orientation="horizontal" >

<ImageView
    android:id="@+id/hora1_current"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:src="@drawable/neutro_on" />

<ImageView
    android:id="@+id/hora2_current"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:src="@drawable/neutro_on" />

<ImageView
    android:id="@+id/minuto1_current"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:src="@drawable/neutro_on" />

<ImageView
    android:id="@+id/minuto2_current"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:src="@drawable/neutro_on" />

Upvotes: 1

Views: 4838

Answers (3)

kirtipriya
kirtipriya

Reputation: 158

Add android:weightSum="1" to your parent linear layout. The linear layout should have android:orientation="horizontal" Now to each of your image views , add android:layout_weight = 0.25.

Hope this works.

Upvotes: 2

Yauraw Gadav
Yauraw Gadav

Reputation: 1746

Don't use wrap content, instead use the actual dimensions of the image or fill parent.

Upvotes: 0

Shailendra Singh Rajawat
Shailendra Singh Rajawat

Reputation: 8242

hope you read enough about orientation vertical and horizontal .

you should clear here that by filling screen whether you mean altogether all 4 fills the screen such that each takes 25% or every one should take 100% width and added up vertically .

  1. for first case add android:layout_weight=1 for every imageView .
  2. for second case replace android:orientation="horizontal" by android:orientation="vertical" in root LinerLayout

Upvotes: 0

Related Questions