ImageView都长宽都match_parent不就全屏了?哪有button的位置?

解决方案 »

  1.   

    ImageView 宽高设置 match_parent 了。
    解决的办法1,改ImageView的宽高设置到需要的大小。
    办法2 ,强行设置Button的size ,来让ImageView挤压。
    办法3, 设置layout_below为null和ImageView 无关,这样Button会盖在ImageView 上层。
    办法...
    按楼主自己的需求处理。
    接点分。
      

  2.   

       <RelativeLayout android:id="@+id/RelativeLayout02"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
        <ImageView 
    android:id="@+id/btn_maininterface"
        android:src="@drawable/btn_maininterface"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
            android:scaleType="fitStart"
    /> 
    imageview全屏了.
    还有,就一个imageview,还搞个relativelayout干吗?
      

  3.   


    @ gqjjqg 现在我想在 ImageView :btn_maininterface  (它是一张大图片)。 在这张大的图片下面 放一个小 icon(也是imageview 加载一张图片)。上面各位朋友说是 match_parent 有问题的,但是不太会改。另外我看到的结果是 btn_maininterface只是占了1/3的屏幕,并没有全屏的。为什么呢?
    <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical" >
         
         <RelativeLayout android:id="@+id/RelativeLayout02"
         android:layout_width="fill_parent"
         android:orientation="vertical"
         android:layout_height="wrap_content"> 
         <ImageView 
         android:id="@+id/btn_maininterface"
         android:src="@drawable/btn_maininterface"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="fitStart"
         /> 
         <ImageView 
     android:id="@+id/btn_tender"
     android:src="@drawable/btn_tender"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_below="@id/btn_maininterface"
    /> 

        </RelativeLayou
      

  4.   

    麻烦会的朋友在帮忙回复下,说下具体的怎么处理吧。就是屏幕显示一张大图片,然后在大图片下面显示 小icon。
      

  5.   

    你imageview的match_parent全部改wrap_content就好了,你看到的效果只有1/3是图片大小,但是你编辑布局xml,在可视话的界面点击第一个imagview可以看到它是铺满的。这种情况还是自己补充基础知识的好
      

  6.   

    占了1/3是因为ImageView的这个属性:android:scaleType="fitStart"如果需要Button在ImageView的下方的话,在Button中添加属性:android:layout_alignParentBottom="true".
      

  7.   

    你imageview的match_parent全部改wrap_content就好了,你看到的效果只有1/3是图片大小,但是你编辑布局xml,在可视话的界面点击第一个imagview可以看到它是铺满的。这种情况还是自己补充基础知识的好@s715575807   谢谢回复
        但是把全部imageview的match_parent全部改wrap_content后,是可以显示 一张图片  和在此图片下显示一个icon。
    但是那张图片高度大概是屏幕的1/4,宽度只有2/3.请问怎么样把加载的图片的宽度填充屏幕的宽度和图片的高度是屏幕高度的1/3呢?麻烦再帮忙回复下吧,这方便不太明白
      

  8.   

    高度非要1/3?那样图片比例不对很容易失真的......一般高度都是自适应的,非要1/3的话用weight
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="3"
        android:orientation="vertical" >
            <ImageView
                android:id="@+id/btn_maininterface"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:src="@drawable/background1" />        <ImageView
                android:id="@+id/btn_click"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/background2">
            </ImageView></LinearLayout>
      

  9.   

    刚才那个要是想图片铺满还要加android:scaleType="fitXY"
      

  10.   


    @ gqjjqg 现在我想在 ImageView :btn_maininterface  (它是一张大图片)。 在这张大的图片下面 放一个小 icon(也是imageview 加载一张图片)。上面各位朋友说是 match_parent 有问题的,但是不太会改。另外我看到的结果是 btn_maininterface只是占了1/3的屏幕,并没有全屏的。为什么呢?
    <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical" >
         
         <RelativeLayout android:id="@+id/RelativeLayout02"
         android:layout_width="fill_parent"
         android:orientation="vertical"
         android:layout_height="wrap_content"> 
         <ImageView 
         android:id="@+id/btn_maininterface"
         android:src="@drawable/btn_maininterface"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="fitStart"
         /> 
         <ImageView 
     android:id="@+id/btn_tender"
     android:src="@drawable/btn_tender"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_below="@id/btn_maininterface"
    /> 

        </RelativeLayou先分析一下这个布局:
    外层是一个竖直线性布局占满全屏,没有问题。
    接下去是个相对布局,宽度满屏, 高度依据内容而定。但是里面有一个多余的属性就是 android:orientation="vertical",相对布局没有方向,这个要去掉。
    在相对布局下有两个ImageView,一个在另外一个下面,宽高虽然都是matchparent,但是如果上面ImageView的内容比屏幕尺寸小,布局仍然会受到上层相对布局的限制,变成是warp_content。所以你这里高度和宽度没有达到你期望的值,是因为实际的图像内容就是屏幕上显示的这么大。要想把加载的图高度填充成和屏幕1:3的比例:
    如果仅仅是作为背景且允许图像拉伸,可以用一个竖直的线性布局,其第一个子View的权重(weight) 属性设置为1放入第二个子View 权重设置为2. 第一个View 用指定的图设置background 或者设置 用ImageView 设置fitXY即可。
    如果允许部分拉伸,就把图制成9patch格式。
    如果不允许拉伸,那么就需要按照不同的屏幕设备,配置不同的背景尺寸。
    当然你也可以代码计算尺寸,然后动态更改布局。总之,android的框架是非常自由的,无论是布局还是代码。
    但是前提是要先理解框架的逻辑设计,并且遵循其框架内的规则。希望能帮到楼主,继续接分。
      

  11.   


    @ gqjjqg 现在我想在 ImageView :btn_maininterface  (它是一张大图片)。 在这张大的图片下面 放一个小 icon(也是imageview 加载一张图片)。上面各位朋友说是 match_parent 有问题的,但是不太会改。另外我看到的结果是 btn_maininterface只是占了1/3的屏幕,并没有全屏的。为什么呢?
    <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical" >
         
         <RelativeLayout android:id="@+id/RelativeLayout02"
         android:layout_width="fill_parent"
         android:orientation="vertical"
         android:layout_height="wrap_content"> 
         <ImageView 
         android:id="@+id/btn_maininterface"
         android:src="@drawable/btn_maininterface"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="fitStart"
         /> 
         <ImageView 
     android:id="@+id/btn_tender"
     android:src="@drawable/btn_tender"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_below="@id/btn_maininterface"
    /> 

        </RelativeLayou先分析一下这个布局:
    外层是一个竖直线性布局占满全屏,没有问题。
    接下去是个相对布局,宽度满屏, 高度依据内容而定。但是里面有一个多余的属性就是 android:orientation="vertical",相对布局没有方向,这个要去掉。
    在相对布局下有两个ImageView,一个在另外一个下面,宽高虽然都是matchparent,但是如果上面ImageView的内容比屏幕尺寸小,布局仍然会受到上层相对布局的限制,变成是warp_content。所以你这里高度和宽度没有达到你期望的值,是因为实际的图像内容就是屏幕上显示的这么大。要想把加载的图高度填充成和屏幕1:3的比例:
    如果仅仅是作为背景且允许图像拉伸,可以用一个竖直的线性布局,其第一个子View的权重(weight) 属性设置为1放入第二个子View 权重设置为2. 第一个View 用指定的图设置background 或者设置 用ImageView 设置fitXY即可。
    如果允许部分拉伸,就把图制成9patch格式。
    如果不允许拉伸,那么就需要按照不同的屏幕设备,配置不同的背景尺寸。
    当然你也可以代码计算尺寸,然后动态更改布局。总之,android的框架是非常自由的,无论是布局还是代码。
    但是前提是要先理解框架的逻辑设计,并且遵循其框架内的规则。希望能帮到楼主,继续接分。谢谢楼上各位朋友热心的回复@gqjjqg 
    为什么会得出以下的结论的呢? 是怎么分析的呢?“在相对布局下有两个ImageView,一个在另外一个下面,宽高虽然都是matchparent,但是如果上面ImageView的内容比屏幕尺寸小,布局仍然会受到上层相对布局的限制,变成是warp_content”但是 在相对布局里边 已经是android:layout_width="fill_parent" 啦为什么会受到上层相对布局的限制而变成 wrap_content.麻烦再回复下,谢啦
      

  12.   


    @ gqjjqg 现在我想在 ImageView :btn_maininterface  (它是一张大图片)。 在这张大的图片下面 放一个小 icon(也是imageview 加载一张图片)。上面各位朋友说是 match_parent 有问题的,但是不太会改。另外我看到的结果是 btn_maininterface只是占了1/3的屏幕,并没有全屏的。为什么呢?
    <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical" >
         
         <RelativeLayout android:id="@+id/RelativeLayout02"
         android:layout_width="fill_parent"
         android:orientation="vertical"
         android:layout_height="wrap_content"> 
         <ImageView 
         android:id="@+id/btn_maininterface"
         android:src="@drawable/btn_maininterface"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="fitStart"
         /> 
         <ImageView 
     android:id="@+id/btn_tender"
     android:src="@drawable/btn_tender"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_below="@id/btn_maininterface"
    /> 

        </RelativeLayou先分析一下这个布局:
    外层是一个竖直线性布局占满全屏,没有问题。
    接下去是个相对布局,宽度满屏, 高度依据内容而定。但是里面有一个多余的属性就是 android:orientation="vertical",相对布局没有方向,这个要去掉。
    在相对布局下有两个ImageView,一个在另外一个下面,宽高虽然都是matchparent,但是如果上面ImageView的内容比屏幕尺寸小,布局仍然会受到上层相对布局的限制,变成是warp_content。所以你这里高度和宽度没有达到你期望的值,是因为实际的图像内容就是屏幕上显示的这么大。要想把加载的图高度填充成和屏幕1:3的比例:
    如果仅仅是作为背景且允许图像拉伸,可以用一个竖直的线性布局,其第一个子View的权重(weight) 属性设置为1放入第二个子View 权重设置为2. 第一个View 用指定的图设置background 或者设置 用ImageView 设置fitXY即可。
    如果允许部分拉伸,就把图制成9patch格式。
    如果不允许拉伸,那么就需要按照不同的屏幕设备,配置不同的背景尺寸。
    当然你也可以代码计算尺寸,然后动态更改布局。总之,android的框架是非常自由的,无论是布局还是代码。
    但是前提是要先理解框架的逻辑设计,并且遵循其框架内的规则。希望能帮到楼主,继续接分。谢谢楼上各位朋友热心的回复@gqjjqg 
    为什么会得出以下的结论的呢? 是怎么分析的呢?“在相对布局下有两个ImageView,一个在另外一个下面,宽高虽然都是matchparent,但是如果上面ImageView的内容比屏幕尺寸小,布局仍然会受到上层相对布局的限制,变成是warp_content”但是 在相对布局里边 已经是android:layout_width="fill_parent" 啦为什么会受到上层相对布局的限制而变成 wrap_content.麻烦再回复下,谢啦是我没写清楚,相对布局 的 宽度是会撑满屏幕,但高度会随着子View内容大小而定。简单来说 相对布局warp_content,但是其content View如果是match_parent,这情况其实是一种矛盾。android的布局逻辑里会优先content View布局,再把相对布局 warp_content,无论宽高均是如此。楼主问的貌似跑题了,为什么button不显示,楼上基本回答清楚了。
      

  13.   

    请问  如果想把一个大图显示在屏幕上方,然后在大图的均匀地显示3个小icon。
    把layout目录下的 xml文件改为如下所示,但是只是显示 一个大图三个小icon没有显示出来。已经在相对布局里边的第一个imageview 使用   
    android:layout_marginTop="10.0dip"
    android:layout_below="@id/btn_maininterface"   但是没有效果请会的朋友麻烦帮忙回复,先谢啦。即想实现的界面:实际效果图:
    <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical" >
        
         <ImageView 
         android:id="@+id/btn_maininterface"
         android:src="@drawable/btn_maininterface"
         android:layout_width="fill_parent"
         android:layout_height="match_parent"
         android:scaleType="fitStart"
         /> 
         
         <RelativeLayout android:id="@+id/RelativeLayout02"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"> 
          <ImageView 
     android:id="@+id/btn_bid"
     android:src="@drawable/btn_bid"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_marginTop="10.0dip"
     android:layout_below="@id/btn_maininterface"
    />

     <ImageView 
     android:id="@+id/btn_der"
     android:src="@drawable/btn_der"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_toRightOf="@id/btn_bid"
     android:layout_alignTop="@id/btn_bid"
     android:layout_weight="1"
    /> 

     <ImageView 
     android:id="@+id/btn_info"
     android:src="@drawable/btn_info"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_toRightOf="@id/btn_der"
     android:layout_alignTop="@id/btn_der"
     android:layout_weight="1"
    /> 
      
    </RelativeLayout>
     </LinearLayout>