我有一个抽屉式布局,其中有一个滚动视图。两者都有Flickable {
id: flickableCanvas
anchors.fill: parent
Item {
id: source
width: Math.max(parent.width,img.width)
height: Math.max(parent.height,img.height)
Image
{
id: img
}
Canvas {
id: myCanvas
}
}
}
Connections {
target: QmlBridge
onLoadImage: {
img.source = p
myCanvas.requestPaint()
flickableCanvas.contentWidth = img.width
flickableCanvas.contentHeight = img.height
}
}
。
我提交了一个片段事务,该事务以线性布局(layout_height="match_parent"
代替滚动视图。
此线性布局还具有fragment_transaction.replace(R.id.scrollView, fragment_seals);
。
但是,线性布局的高度与父级的高度不匹配(抽屉式布局,因为它替代了滚动视图,后者是抽屉式布局的子级)。你知道为什么吗?
抽屉布局是根。
抽屉布局正确匹配其“父级”(设备的视口/屏幕),我将其签出。但是线性布局只是包装了自己的内容,我敢肯定是100%。
layout_height="match_parent"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/seals_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorRichYellow"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/choose_seal" />
<ListView
android:id="@+id/handle_publication_share_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp" />
</LinearLayout>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemBackground="@color/color_states_menu"
app:menu="@menu/drawer_view">
<ImageView
android:id="@+id/logo_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_gravity="bottom"
android:src="@drawable/baseline_share_black_18dp"
android:background="@color/colorRoyalRedLight"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraint_layout_bottom"/>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>