首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的图像视图没有得到填充父母。

我的图像视图没有得到填充父母。
EN

Stack Overflow用户
提问于 2015-04-26 12:12:29
回答 1查看 65关注 0票数 0

我的图像视图没有在布局中设置fill-parent。我有一些大小为500*375300*215的图片。我将我的图像视图完全设置为fill-parent,但是它出现在页面的中心,没有完整的填充。

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:id="@+id/main_matn_layout"
            android:background="@drawable/backmainmatn"
            android:layout_height="match_parent">


<ir.adad.AdView
        android:id="@+id/ad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/star"
        android:layout_toRightOf="@+id/main_matn_i_next"
        android:layout_toLeftOf="@+id/main_matn_i_pre"
        android:layout_above="@+id/imgb"
        />


<ImageButton   android:id="@+id/imgb"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_alignParentBottom="true"
               android:layout_gravity="center"
               android:background="@drawable/star"
               android:layout_toRightOf="@+id/main_matn_i_next"
               android:layout_toLeftOf="@+id/main_matn_i_pre"
        />


<ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/ad"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true">

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

        <TextView
                android:id="@+id/main_matn_titr"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_alignParentRight="true"
                android:layout_marginRight="10dp"
                android:gravity="right"
                android:textColor="@android:color/black"
                android:layout_marginTop="20dp"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textSize="30sp"/>

        <ImageView
                android:id="@+id/main_matn_share"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:src="@drawable/share"/>
        <ImageView
                android:id="@+id/main_matn_img"
                android:layout_width="fill_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_height="fill_parent"
                />

        <TextView
                android:id="@+id/main_matn_matn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_margin="20dp"
                android:textColor="@android:color/black"
                android:gravity="right"
                android:text="TextView"/>

    </LinearLayout>
</ScrollView>

<ImageView
        android:id="@+id/main_matn_i_next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:src="@drawable/back"/>

<ImageView
        android:id="@+id/main_matn_i_pre"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/next"/>

我想做我的imageview fill-parent

代码语言:javascript
复制
<ImageView
    android:id="@+id/main_matn_img"
    android:layout_width="fill_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_height="fill_parent"
    />

在模拟器中,它看起来是正确的,但是当我运行我的项目时,它没有出现。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-26 12:25:21

首先,不建议使用fill_parent,您应该使用match_parent

尽管如此,我猜这可能是一个scaleType问题。为了检查您的ImageView实际上是否正在填充它的父服务器,我建议设置一个背景色:

代码语言:javascript
复制
android:background="#FF0000"

要确保位图实际填充其ImageView容器,请尝试更适合您需要的scaleType

代码语言:javascript
复制
android:scaleType="centerCrop"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29877459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档