Android 调整背景图像大小
大家好,我想调整一个样式的图像背景的大小,我有一个使用该样式并显示背景图像的图像视图 风格:Android 调整背景图像大小,android,android-layout,screen-size,Android,Android Layout,Screen Size,大家好,我想调整一个样式的图像背景的大小,我有一个使用该样式并显示背景图像的图像视图 风格: <style name="Background"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">50dp</item> <item name="androi
<style name="Background">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">50dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/img_background</item>
</style>
匹配父项
50dp
水平的
@可绘制/图像背景
所以我有“img_背景”,它的大小大约是1920*1080,我想调整它的大小,使它适合所有设备的大小,如何使它根据屏幕大小自动调整大小?因为它不起作用
它不能正确地显示图像,并且没有正确地调整大小以适应屏幕
我有一个线性布局,里面有样式和图像视图。它不适合1920*1080,例如,在800*480分辨率中,它被裁剪,并且没有整齐地调整大小
<LinearLayout
style="@style/Background"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:contentDescription="@null"
android:layout_marginBottom="8dip"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dip"
android:layout_marginTop="8dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:paddingLeft="15dip"
android:src="@drawable/img_background"
/>
</LinearLayout>
谢谢从
线性布局中删除样式
将其作为您的图像视图:
<ImageView
android:contentDescription="@null"
android:layout_marginBottom="8dip"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dip"
android:layout_marginTop="8dip"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:clickable="false"
android:paddingLeft="15dip"
android:scaleType="centerInside"
android:src="@drawable/img_background" />
更改xml的布局宽度和布局高度
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
填充父对象
填补家长的空缺
use:android:layout\u width=“match\u parent”和android:layout\u height=“match\u parent”是否只想将其设置为50dp高?是的,我的Imageview很小,我想正确调整宽度大小,图像是一个宽度很长的横幅,好的,我已经编辑了我的答案…谢谢,但没用,我正在使用线性布局应用该样式,然后将ImageView放入其中。像这样检查OP的更新Hi不起作用,检查OP我更新更多信息谢谢