【问题标题】:Change the Image Size without changing its Place Holder更改图像大小而不更改其占位符
【发布时间】:2018-10-06 15:02:40
【问题描述】:

我在水平线性布局中有一些 ImageView。我将它们的大小设置为百分比模式。

<LinearLayout
android:weightSum="1"
android:orientation="horizontal" >

    <ImageButton
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.25"
    android:scaleType="fitStart"
    android:src="@drawable/pjc_news_icon" />

</LinearLayout>

现在,如果我将我的软件安装在小型设备中,图像的宽度会变小以适应其父布局的指定百分比。他们的高度也会变小。但他们的占位符的高度没有改变。我的意思是他们的底部有一个无用的空白区域。

【问题讨论】:

  • 请在此处粘贴完整的 xml。

标签: android image size


【解决方案1】:

尝试添加另一个视图以覆盖剩余空间。

<LinearLayout
android:weightSum="1"
android:orientation="horizontal" >

<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:scaleType="fitStart"
android:src="@drawable/pjc_news_icon" />

<View 
  android:layout_width="0dp"
  android:layout_height="1dp"
  android:layout_weight="0.75"   
/>

</LinearLayout>

试试这个,希望它对你有用。

【讨论】:

    【解决方案2】:

    我自己找到了答案。

    我将“adjustViewBounds”属性添加到我的 ImageView 并将其值设置为 true。然后 ImageView 下面的空间被移除了。

    <LinearLayout
    android:weightSum="1"
    android:orientation="horizontal" >
    
        <ImageButton
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:scaleType="fitStart"
        android:src="@drawable/pjc_news_icon" />
    
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 2019-06-28
      • 2019-05-23
      • 1970-01-01
      • 2020-02-23
      • 2015-07-09
      • 1970-01-01
      • 2012-08-14
      • 1970-01-01
      • 2015-12-14
      相关资源
      最近更新 更多