Android 布局中的框

Android 布局中的框,android,android-layout,xamarin,Android,Android Layout,Xamarin,好的,首先,我有一个背景图像,它有一些边界,必须匹配给定的布局 我目前的方法是在一个布局框,也许有一个完全不同的解决方案 因此,15%左右的利润率,10%底部和顶部的利润率,我已经有了左右的利润率,下面的代码,但我也在努力将顶部和底部的利润率放在同一个布局中 您可以对百分比大小使用PercentRelativeLayout,如下所示 <android.support.percent.PercentRelativeLayout xmlns:android="http://sche

好的,首先,我有一个背景图像,它有一些边界,必须匹配给定的布局

我目前的方法是在一个布局框,也许有一个完全不同的解决方案

因此,15%左右的利润率,10%底部和顶部的利润率,我已经有了左右的利润率,下面的代码,但我也在努力将顶部和底部的利润率放在同一个布局中


您可以对百分比大小使用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">

 <ImageView
     app:layout_widthPercent="50%"
     app:layout_heightPercent="50%"
     app:layout_marginTopPercent="25%"
     app:layout_marginLeftPercent="25%"/>

 </android.support.percent.PercentRelativeLayout>

您可以对百分比大小使用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">

 <ImageView
     app:layout_widthPercent="50%"
     app:layout_heightPercent="50%"
     app:layout_marginTopPercent="25%"
     app:layout_marginLeftPercent="25%"/>

 </android.support.percent.PercentRelativeLayout>


你想把盒子放在屏幕中间,这样两边的边距就相等了吗?让我们说不,这应该适用于不同的图像,为了测试目的,我使用了相同的边距,这样就更容易滤除错误了。你想把这个盒子放在屏幕中间,这样两边的边距就相等了吗?我使用相同的裕度只是为了测试目的,所以更容易过滤掉这方面的错误。