Android基于百分比尺寸和边距的百分比支持库

代码

<android.support.percent.PercentRelativeLayout>
 <ImageView
  android:id=”@+id/centered_image”
  android:layout_gravity=”center”
  app:layout_widthPercent=”50%”
  app:layout_heightPercent=”50%” />
 <TextView
  android:id=”@+id/caption”
  android:layout_width=”wrap_content”
  android:layout_height=”wrap_content”
  android:layout_below=”@id/centered_image”
  android:layout_gravity=”center_horizontal”
  app:layout_marginStartPercent=”25%”
  app:layout_marginEndPercent=”25%” />
</android.support.percent.PercentRelativeLayout>

Gradle导入

com.android.support:percent:23.0.0

Maven导入

<groupId>com.android.support</groupId>

<artifactId>percent</artifactId>
<version>23.0.0</version>

原文

Percent Support Library


The Percent package provides APIs to support adding and managing
percentage based dimensions in your app.

The Percent Support library adds support for the PercentLayoutHelper.PercentLayoutParams interface
and various classes, such as PercentFrameLayout and PercentRelativeLayout.

After you download the Android Support Libraries, this library is located in the<sdk>/extras/android/support/customtabs directory. For more information on how to set up your project, follow the instructions in Adding
libraries with resources
.

The Gradle build script dependency identifier for this library is as follows:

com.android.support:percent:23.0.0

« »

发表评论

电子邮件地址不会被公开。 必填项已用*标注

昵称 *