Jos*_*ird 4 android android-xml
我将如何让我的晶圆厂ConstraintLayout像我一样跨越两个布局CoordinatorLayout?
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eeeeee"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/myToolbar"
android:layout_width="384dp"
android:layout_height="56dp"
android:background="@color/colorPrimary"
android:elevation="0dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
app:layout_anchor="@+id/tvTest"
app:layout_anchorGravity="end|bottom|right"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"/>
<CustomViews.FontText
android:id="@+id/tvTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="50dp"
android:text="TestText"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/myToolbar"/>
Run Code Online (Sandbox Code Playgroud)
例如,您有两个 Layout ,
布局 1 -> id="@+id/above_layout" , 布局 2 -> id="@+id/below_layout" ,
然后,并且您想在布局 1 和布局 2 之间设置 Fab Action Button,
应用程序:layout_constraintRight_toRightOf="parent"
->这将看到右侧
app:layout_constraintBottom_toBottomOf="@+id/above_layout", app:layout_constraintTop_toBottomOf="@+id/above_layout"
-->这两个 prop 会实现 app:layout_anchor="@+id/tvTest" ,app:layout_anchorGravity="end|bottom|right" 的效果,并且 layout 的 id 应该是一样的。
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
android:scaleType="center"
android:src="@drawable/ic_star"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="@+id/above_layout"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/above_layout"/>
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助。
| 归档时间: |
|
| 查看次数: |
2792 次 |
| 最近记录: |