Android 如何将垂直基准转换为百分比

Android 如何将垂直基准转换为百分比,android,android-layout,android-studio,android-fragments,android-constraintlayout,Android,Android Layout,Android Studio,Android Fragments,Android Constraintlayout,这看起来很简单,在添加垂直指南后,当你点击上方的箭头时,它会变成百分比,但我的android studio、我正在使用的约束布局版本或可能我在这里做了一些非常错误的事情 我已经尝试了所有的方法,但是当我点击它的时候,它总是显示相同的arrow,并且从来没有变成百分比 我正在使用安卓Studio 2.2,并将其添加到我的gradle中 编译'com.android.support.constraint:constraint布局:1.0.0-beta4' 请指导我如何将其转换为百分比。您可以使用

这看起来很简单,在添加垂直指南后,当你点击上方的箭头时,它会变成百分比,但我的android studio、我正在使用的约束布局版本或可能我在这里做了一些非常错误的事情

我已经尝试了所有的方法,但是当我点击它的时候,它总是显示相同的arrow,并且从来没有变成百分比

我正在使用安卓Studio 2.2,并将其添加到我的gradle中

编译'com.android.support.constraint:constraint布局:1.0.0-beta4'

请指导我如何将其转换为百分比。

您可以使用

Percent软件包提供了支持添加和管理的API 应用程序中基于百分比的维度

向Gradle构建脚本添加依赖项,根据项目更改版本:

compile 'com.android.support:percent:24.2.1'
在布局中,可以添加一个

您可以使用属性指定子对象的尺寸或边距 带有“百分比”后缀

例如:

<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">
     <ImageView
         app:layout_widthPercent="50%"
         app:layout_heightPercent="50%"
         app:layout_marginTopPercent="25%"
         app:layout_marginLeftPercent="25%"/>
 </android.support.percent.PercentRelativeLayout>

您可以使用

Percent软件包提供了支持添加和管理的API 应用程序中基于百分比的维度

向Gradle构建脚本添加依赖项,根据项目更改版本:

compile 'com.android.support:percent:24.2.1'
在布局中,可以添加一个

您可以使用属性指定子对象的尺寸或边距 带有“百分比”后缀

例如:

<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">
     <ImageView
         app:layout_widthPercent="50%"
         app:layout_heightPercent="50%"
         app:layout_marginTopPercent="25%"
         app:layout_marginLeftPercent="25%"/>
 </android.support.percent.PercentRelativeLayout>

它在Android Studio 2.3中使用

compile 'com.android.support.constraint:constraint-layout:1.0.1'
然而,在使用上有几个问题。有时图标隐藏在其他项目下,因此很难单击,而有时单击图标会选择下面的内容。我发现你有时需要放大很多,然后在小三角形的图标中间点击右键。单击一次将反转指南的方向,单击两次将其转换为百分比

如果失败,您可以直接更改xml。替换

app:layout_constraintGuide_begin="51dp"


例如。

它在Android Studio 2.3中使用

compile 'com.android.support.constraint:constraint-layout:1.0.1'
然而,在使用上有几个问题。有时图标隐藏在其他项目下,因此很难单击,而有时单击图标会选择下面的内容。我发现你有时需要放大很多,然后在小三角形的图标中间点击右键。单击一次将反转指南的方向,单击两次将其转换为百分比

如果失败,您可以直接更改xml。替换

app:layout_constraintGuide_begin="51dp"


例如。

或者,尝试使用android.support.percent.PercentRelativeLayout或PercentFrameLayout视图(您可以在support libraries-com.android.support:percent中找到这些视图)。然后,您可以对其子项使用app:layout_widthPercent=“num%”或类似约束。或者,尝试使用android.support.percent.PercentRelativeLayout或PercentFrameLayout视图(您可以在支持库-com.android.support:percent中找到这些视图)。然后,您可以对其子级使用app:layout_widthPercent=“num%”或类似约束。