如何在样式中使用约束属性?
当我尝试将其用作具有自定义命名空间的任何其他属性时,它对我的视图没有影响.
<style name="Header.Center" parent="Header">
<item name="layout_constraintBottom_toBottomOf">parent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
添加命名空间应用程序:没有帮助.
Paw*_*ski 12
首先,确保View你正在应用风格的是直接的孩子ConstraintLayout.否则,定位时不会考虑约束View.
我已经尝试过了,你尝试的方式确实有效.我已将以下样式添加到styles.xml:
<style name="CustomStyle">
<item name="layout_constraintBottom_toBottomOf">parent</item>
<item name="layout_constraintEnd_toEndOf">parent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
创建了一个基本布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CustomStyle"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
它确实位于TextView父母的右下角.
| 归档时间: |
|
| 查看次数: |
2562 次 |
| 最近记录: |