2

ImageView在这张图片上有一个(人体)和按钮。 在此处输入图像描述

是否有可能以某种方式轻松地RelativeLayout为最不同的屏幕尺寸创建它?或者我应该为不同的屏幕尺寸创建不同的布局?

你将如何进行?你有什么建议吗?

4

3 回答 3

3

看看百分比库

它非常适合这样的事情,并且适用于所有设备。您必须计算出每个 PercentRelativeLayout 相对于您的人物图像的百分比宽度、高度和边距。

这是一个例子:

<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View
        app:layout_widthPercent="25%"
        android:layout_height="100dp"
        app:layout_marginLeftPercent="5%"
        android:background="#ff0000" />

</android.support.percent.PercentRelativeLayout>

并记得

compile 'com.android.support:percent:23.0.0'
于 2015-09-22T13:33:57.973 回答
1

这是一个带有可点击区域的图像视图示例。

https://blahti.wordpress.com/2012/06/26/images-with-clickable-areas/

我希望它对你有帮助。

于 2015-09-22T13:37:10.867 回答
0

是的,相对布局是可能的,但它很困难。

为此,您必须专注于

  1. 完美切割的不同图像。
  2. 将图像放入所有可绘制对象中。
  3. 创建相对布局并从一侧到另一侧的图像视图作为参考。
  4. 在不同的dimen.xml中添加边距
于 2015-09-22T13:36:16.173 回答