【发布时间】:2020-03-17 13:58:23
【问题描述】:
我正在尝试将两个浮动按钮并排放置,我尝试使用设计视图移动它,但我无法移动它返回到同一个位置的按钮。
我仍然对 ConstraintLayout、RelativeLayout 和 LinearLayout 术语感到困惑。
根据我的阅读,LinearLayout 是用于水平视图的,所以我尝试更改布局的宽度和高度以包装内容
这是我目前的结果
activity_main
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="9dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/resultText"
android:layout_width="363dp"
android:layout_height="wrap_content"
android:autoLink="all"
android:autofillHints="text edit"
android:background="@drawable/bg_edit"
android:gravity="top"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/saveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/pdfBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
【问题讨论】:
标签: android android-layout android-button