Android 更改图像大小而不更改其占位符
我有一些水平直线布局的图像视图。我以百分比模式设置它们的大小Android 更改图像大小而不更改其占位符,android,image,size,Android,Image,Size,我有一些水平直线布局的图像视图。我以百分比模式设置它们的大小 <LinearLayout android:weightSum="1" android:orientation="horizontal" > <ImageButton android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.25" android:scal
<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>
现在,如果我在一个小尺寸的设备上安装我的软件,图像的宽度将变小,以适应其父布局的指定百分比。它们的高度也会变小。但是他们的位置持有者的高度没有改变。我的意思是,它们的底部有一个无用的空格。尝试添加另一个视图,以便它覆盖剩余的空间
<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>
试试这个,希望它对你有用。我自己找到了答案 我将adjustViewBounds属性添加到ImageView并将其值设置为true。然后,图像视图下方的空间被删除
<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粘贴到此处。