Android - 将按钮放在 ImageView 上的确切位置

标签 android android-layout android-imageview android-button android-percentrelativelayout

我在该图像上有一个 ImageView (人体)和按钮。 enter image description here

是否可以以某种方式轻松地在 RelativeLayout 中为大多数不同的屏幕尺寸创建此内容?或者我应该为不同的屏幕尺寸创建不同的布局?

你将如何进行?你有什么推荐?

最佳答案

看看 percent library

它非常适合这样的事情,并且适用于所有设备。您必须计算出每个 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'

关于Android - 将按钮放在 ImageView 上的确切位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32718087/

相关文章:

android - 拖放 imageview android

java - 单击菜单后调用另一个 Activity

android - GrivView BaseAdapter 中的绝对位置

android - 如何在从url加载的ImageView中淡入图片

android - 在 recyclerview 适配器 android 中选择适配器中的项目

java - 每次应用程序启动时 AlarmManager 都会触发

java - android:如何在应用程序被杀死时清理应用程序

android - 带有 Phonegap 的 Android 混合应用程序上的 Iframe 视频

android - 如何将 varchar 从 sql server 转换为 android 中的图像

android - android中Imageview的按钮类点击效果