u2g*_*les 15 android android-resources android-percent-library
似乎新的百分比支持库已发布,但不允许在维度xml文件中引用百分比值.
也就是说,而不是:
<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.PercentFrameLayout/>
Run Code Online (Sandbox Code Playgroud)
能够编写类似的代码:
<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="@percent/myWidthPercent"
app:layout_heightPercent="@percent/my/HeightPercent"
app:layout_marginTopPercent="@percent/myMarginTophPercent"
app:layout_marginLeftPercent="@percent/myMarginLeftPercent"/>
Run Code Online (Sandbox Code Playgroud)
其中myWidthPercent在资源文件中定义.
我错了(我是否错过了另一个名字)或者是我们可以发送给谷歌的功能请求?
Ily*_*kov 29
使用分数而不是百分比
<resources>
<fraction name="myWidthPercent">50%</fraction>
...
</resources>
Run Code Online (Sandbox Code Playgroud)
并参考它
<ImageView
app:layout_widthPercent="@fraction/myWidthPercent"
app:layout_heightPercent="@fraction/my/HeightPercent"
app:layout_marginTopPercent="@fraction/myMarginTophPercent"
app:layout_marginLeftPercent="@fraction/myMarginLeftPercent"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1190 次 |
| 最近记录: |