English 中文(简体)
海底布局内的图像调查并不适合屏幕大小。
原标题: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" />

最佳回答

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.

希望这项工作。

问题回答

希望你们充分了解方向和横向方向。

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

不使用包裹,而是使用图像的实际尺寸或填充父母。





相关问题
Very basic WPF layout question

How do I get this listbox to be maxiumum size, i.e. fill the group box its in. I ve tried width="auto" Height="auto", width="stretch" Height="stretch" annoyingly at the moment, it dynamicly sizes to ...

How to align the text to top of TextView?

How to align the text to top of a TextView? Equivalent Android API for Swings setInsets()? that is top of text should start be in (0,0) of TextView <?xml version="1.0" encoding="utf-8"?> <...

Centring a flow in Shoes

Can I center the contents of a flow in Shoes? I know that a paragraph can be centred like: para Centred paragrpah , :align=> center However, this does not work with flows: flow(:align=> ...

Overlaying with CSS

I want to load a website in an iframe, and overlay the website with some hints about the website that is shown. However, i got stuck at the point that the website has a variable passive white space at ...

How do you normally make a program look beautiful? [closed]

How can I make an Application look nice and not like an amateur pulled it together? I mean graphic-wise. Is there some sort of book you can read regarding beautiful program layouts, etc? I put this ...

热门标签