繁体   English   中英

我在图像视图的设计上有问题

[英]I have a problem in the design of image view

我想使用嵌套滚动视图显示项目的图像及其详细信息垂直,但我在图像视图中出现问题,它出现在挂起状态,我不知道为什么。

'''<?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" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM