【问题标题】:ImageView doesn't fit the ImageImageView 不适合图像
【发布时间】:2016-05-30 19:53:15
【问题描述】:

我有这个 Layout ,当我尝试将 Image (src="Image") 放入任何 ImageView 时,Image 扩展了 ImageView 边框并覆盖了整个屏幕,这是我的 Layout 的一部分

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight=".5"
        android:orientation="vertical"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight=".5"
            android:id="@+id/firstFrame"
            android:layout_margin="@dimen/LayoutMargin"
            android:elevation="6dp"
            android:background="@color/frame1"
            android:orientation="horizontal"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/imageView"
                android:layout_gravity="left|center_vertical"
                android:layout_weight=".5"
                />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight=".5"
                android:orientation="vertical"
                >
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight=".5"
                    android:gravity="center"
                    android:scaleType="centerCrop"
                    />
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight=".5"
                    android:gravity="center"
                    android:scaleType="centerCrop"
                    />

            </LinearLayout>
        </LinearLayout>

我希望图像位于 ImageView 边框内, 请问有什么解决办法吗?

【问题讨论】:

  • android:scaleType="fitCenter" 在每个图像视图中使用此行代码。它是在 imageview 中调整您的图像...
  • 你没有正确使用权重。
  • 它不起作用 ,,, 所有 ScalType 类型都不起作用
  • 重量问题出在哪里,请告诉我
  • Wights 要求加权尺寸(只能是一个)为 0dp

标签: android xml imageview android-linearlayout


【解决方案1】:

问题出在第一个LinearLayout上,一定是sumWeight而不是layout_weight,或者你的结构不完整。

【讨论】:

  • 兄弟,,,你看到的LinearLayout,它只是另一个LinearLayout的一部分
  • 哦,你应该插入你的整个结构,所以帮助可能是正确的。
  • 它太大了
【解决方案2】:

问题在于重量 如果你使用线性布局作为(水平)所以你应该把宽度= 0dp 然后你把你想要的重量, 垂直方向反之亦然

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    相关资源
    最近更新 更多