我想使用嵌套滚动视图在垂直方向显示项目的图像,但我在下面的图像视图中有问题,它显示为未决,我不知道为什么
'''<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".ui.ItemDetialsActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<androidx.appcompat.widget.Toolbar
android:layout_height="350dp"
android:layout_width="match_parent"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways">
<ImageView
android:id="@+id/image_item_diteals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="fitXY"
android:src="@drawable/omla3"
app:layout_collapseMode="parallax"/>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
在图像的此处图像左侧有一条绿线,我希望它与父代相匹配我希望图像从左到右开始
这是我的完整xml文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".ui.ItemDetialsActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<androidx.appcompat.widget.Toolbar
android:layout_height="350dp"
android:layout_width="match_parent"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways">
<ImageView
android:id="@+id/image_item_diteals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="fitXY"
android:src="@drawable/omla3"
app:layout_collapseMode="parallax"/>
</androidx.appcompat.widget.Toolbar>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:clipToPadding="false"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/item_namedetails"
android:layout_marginTop="10dp"
android:padding="12dp"
android:text="Item name"
android:textColor="@color/colorPrimary"
android:textSize="20sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
app:cardElevation="8dp"
app:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/fooddescrition"
android:layout_marginTop="12dp"
android:lineSpacingMultiplier="1.5"
android:padding="12dp"
android:text="ful description"
android:textColor="@android:color/black"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:id="@+id/layoutprice"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_weight="1"
android:layout_width="0dp"
android:src="@drawable/ic_attach_money_black_24dp"
android:layout_height="match_parent" />
<TextView
android:id="@+id/foodpricedetails"
android:layout_marginTop="10dp"
android:padding="12dp"
android:text="1000"
android:textColor="@color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="9"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
将这些属性添加到工具栏以省略边距:
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp" />