【问题标题】:How to alter image size in android?如何在android中更改图像大小?
【发布时间】:2019-12-05 17:59:38
【问题描述】:
【问题讨论】:
标签:
android
xml
imageview
【解决方案1】:
解决方案:
1、从RelativeLayout中去掉两个LinearLayout。然后将 imageView 添加为 RelativeLayout 的子项。然后,设置ImageView的属性android:layout_width="wrap_content" android:layout_height="wrap_content"。然后,您的图像将与屏幕尺寸相关。
建议:阅读Developer Docs 了解Layouts 和所有内容。
我希望它有所帮助。如果您对我的回答有任何不明白的地方,请告诉我。
代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/american_style_pool_table_diagram"
tools:context=".MainActivity"
android:layout_weight="5">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="401dp"
android:layout_marginTop="92dp"
android:contentDescription="image"
android:scrollbarSize="4dp"
app:srcCompat="@drawable/acecardpngcardsacespades600" />
</RelativeLayout>
给定代码的预览:
- 当您想添加一些代码时,只需复制代码并粘贴到您的详细信息下方,然后仅选择代码部分,然后按“代码示例”按钮(从左到右的第 5 个按钮右)从上面。查看这些:
选择代码:
然后按下这个按钮: