2011-11-22 58 views
1

我已将图像添加到我的xml文件。这是我正在使用的代码:Android布局 - 占用额外空间的图像

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/topbar_logo2x" 
     android:scaleType="fitStart" /> 

    <TabHost 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@android:id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

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

      <View 
       android:layout_width="fill_parent" 
       android:layout_height="0.5dip" 
       android:background="#000" /> 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="0dip" 
       android:layout_marginRight="0dip" /> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
     </LinearLayout> 
    </TabHost> 
</LinearLayout> 

我希望我的TabHost完全位于我的图像之上。当我在StackOverflow上签了一些答案,我得到了说明使用

android:scaleType="fitStart" 

我想使用相同的ImageView都android:scaleType="fitStart"android:scaleType="fitEnd",这是不可能的答案Sndroid将使scaleType只有一个声明。如何通过代码更改来实现同样的功能?有其他的命令能帮助我吗?

enter image description here

+0

所以你想'TabHost'高于'ImageView'?如何在XML中将“TabHost”移动到它上面? –

+0

没有雅诺,我希望我的图片在页面顶部(公司徽标),然后是TabHost – Vinoth

+0

没有雅诺,我希望我的图片位于页面顶部(公司徽标),然后是TabHost – Vinoth

回答

2

在我看来较大黑线必须来自图像(topbar_logo2x),或者它被缩放到ImageView的方式。尝试使用scaleType="fitXY"来查看上面的黑线是否消失。如果没有,然后张贴图片让我们看看。

对我来说View低于LinearLayout会导致较小的黑线。去掉它。

+1

感谢您的回复亚诺!它按我想要的那样工作。 – Vinoth