【发布时间】:2017-10-12 12:40:46
【问题描述】:
我使用 Coordinator Layout 作为父布局来锚定一个图像,使用 Linear 布局作为子布局。所以可能的问题是我怎样才能使屏幕可滚动?线性布局分为两个具有权重的孩子。请在下面找到xml代码:
我已经尝试使用嵌套滚动视图和普通滚动视图进行此操作,但屏幕划分会受到干扰,这是通过线性布局权重总和属性完成的。
<android.support.design.widget.CoordinatorLayout 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="@drawable/bg_welcome">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10"
tools:context="com.rblbank.mobank.chequebook.fragments.NewChequeBookFragment">
<TextView
android:id="@+id/tvNewChequeBook"
style="?attr/title_1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center"
android:padding="@dimen/activity_horizontal_margin"
android:text="@string/new_cheque_book_title_note"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:background="@color/white_color"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="@dimen/padding_12">
<TextView
android:id="@+id/tvNewChequeBookInvestmentAccountTitle"
style="?attr/title_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:text="@string/investment_account"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="@color/black_color" />
<TextView
android:id="@+id/tvNewChequeBookInvestmentAccount"
style="?attr/newChequeBookInvestmentAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:textColor="@color/arrow_grey" />
<View
android:id="@+id/vwAccountDetailsHorizontalDivider"
android:layout_width="match_parent"
android:layout_height="@dimen/divider_width"
android:layout_marginBottom="@dimen/minimum_margin"
android:layout_marginTop="@dimen/minimum_margin"
android:background="@color/home_functionality_divider" />
<TextView
android:id="@+id/tvNewChequeBookAddressNote"
style="?attr/newChequeBookAddressNoteStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin" />
<TextView
android:id="@+id/tvNewChequeBookAddress"
style="?attr/newChequeBookAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin" />
<Button
android:id="@+id/btnewChequeBookDeliverCheque"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:text="@string/deliver_cheque_book_to_above_address" />
<TextView
android:id="@+id/tvNewChequeBookAddressChanged"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:text="@string/postal_address_has_changed" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/ivNewChequeBookPostBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_action_submit"
app:layout_anchor="@id/tvNewChequeBook"
app:layout_anchorGravity="center_horizontal|bottom"
app:layout_behavior="com.rblbank.mobank.ScrollAwareFABBehavior" />
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
标签: android android-coordinatorlayout