Reputation: 11
I'm developing my first Android application, and I would like to build a main meno with two consecutive images an then a TabWidget with some tabs. I'm using Android 2.3.
I don't know why but, between the imges, it appears some white space that looks so ugly...I'm triyng all the time modifying paddin and margin but no works... Anyone knows what happens?
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- android:background="#000000" -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView android:id="@+id/TwiceBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/twice_bar"
android:scaleType="fitStart"
/>
<ImageView
android:id="@+id/Banner_publicidad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/banner_publicidad"
android:scaleType="fitStart" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</TabHost>
Thanks in advance for your help!
Upvotes: 1
Views: 2942
Reputation: 13129
Bit of a tweak, fitStart
will only move the image to the top/left of the image view, it wont fill the space.
cropCenter
allow the image to fill the space by how you ask it, So if the image view is wider than the image, meaning that it need to crop the bottom and top to fill the space, it will do so.
Generally the Center
scaleTypes are the best to use to fill the space.
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="@+id/TwiceBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/twice_bar"
android:scaleType="centerCrop"
/>
<ImageView
android:id="@+id/Banner_publicidad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/banner_publicidad"
android:scaleType="centerCrop" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Upvotes: 0
Reputation: 752
Have you tried adding android:adjustViewBounds="true" to your ImageViews?
Upvotes: 6