【发布时间】:2018-02-19 12:52:37
【问题描述】:
我有 3 张 PNG 格式的图像。它们具有相同的分辨率,我希望它们在相对布局中彼此相邻。我希望它具有响应性,例如图像视图应根据提供的空间调整它们的大小。我不想在 dps 中给出固定的高度和宽度,例如:
<ImageView
android:layout_width="60dp"
android:layout_height="100dp"/>
如果我尝试像这样定义宽度和高度:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
如果我这样做,它们太大了。我该怎么办?有什么建议吗?
编辑: 代码如下:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/streetlong">
<ImageView
android:layout_width="60dp"
android:layout_height="100dp"
android:id="@+id/btn_hospital"
android:onClick="onClick"
android:background="@drawable/hospital"
/>
<ImageView
android:id="@+id/btn_pharmacy"
android:layout_width="60dp"
android:layout_height="100dp"
android:layout_marginLeft="@dimen/_15sdp"
android:onClick="onClick"
android:layout_toRightOf="@+id/btn_hospital"
android:layout_toEndOf="@+id/btn_hospital"
android:background="@drawable/pharmacys" />
<ImageView
android:id="@+id/btn_police"
android:layout_width="60dp"
android:layout_height="100dp"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_toRightOf="@+id/btn_pharmacy"
android:layout_toEndOf="@+id/btn_pharmacy"
android:layout_weight="1"
android:background="@drawable/polices"
android:onClick="onClick" />
</RelativeLayout>
我希望图像视图根据屏幕大小进行调整,我不想给它们设置高度和宽度
【问题讨论】:
-
使用一种水平线性布局。将 3 个图像视图放入其中。在每个图像视图中将权重添加到 1
标签: android android-imageview android-relativelayout