在我的在线食品订购应用程序中,在食品详细信息部分,图像位置不正确。我从firebase数据库导入它。
这是我的fooddetail.java代码
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.example.admin.clicknorder.FoodDetail"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layout_scrollFlags="exitUntilCollapsed"
app:contentScrim="#0d0e0d"
app:expandedTitleTextAppearance="@android:color/transparent"
>
</android.support.design.widget.CollapsingToolbarLayout>
<ImageView
android:id="@+id/image_food"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
app:layout_collapseMode="parallax"
android:scaleType="fitXY"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:title="Food Name"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax"
/>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/btnCart"
app:srcCompat="@drawable/ic_shopping_cart_black_24dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end"
app:useCompatPadding="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.v4.widget.NestedScrollView
android:id="@+id/nesterScrollView"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.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/food_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="12dp"
android:text="Food Name"
android:textColor="@color/colorPrimary"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:orientation="horizontal"
android:id="@+id/layout_price"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
app:srcCompat="@drawable/ic_attach_money_black_24dp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/food_price"
android:layout_weight="9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="1,000"
android:textColor="@color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
android:layout_width="100dp"
android:layout_height="30dp"
android:id="@+id/number_button"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginBottom="18dp"
app:textSize="8sp"
app:backGroundColor="@color/colorAccent"
app:initialNumber="1"
app:finalNumber="20"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
app:cardElevation="5dp"
app:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/food_description"
android:layout_marginTop="12dp"
android:lineSpacingMultiplier="1.5"
android:padding="12dp"
android:text="description"
android:textColor="@android:color/black"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
我不知道发生了什么,但如果它与图像分辨率和大小有关,请告诉我如何从android studio本身修复它。
如果需要更多细节......我将编辑我的问题。 谢谢
答案 0 :(得分:0)
您刚刚将 ImageView
和 Toolbar
放在错误的位置
将您的image_food
ImageView
和 Toolbar
移到CollapsingToolbarLayout
<?xml version="1.0" encoding="utf-8"?>
<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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title=""
app:titleEnabled="false">
<ImageView
android:id="@+id/image_food"
android:layout_width="match_parent"
android:layout_height="256dp"
android:contentDescription="@null"
android:scaleType="fitXY"
android:src="@drawable/kid_goku"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/btnCart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:elevation="6dp"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end"
app:pressedTranslationZ="12dp"
app:srcCompat="@drawable/ic_message"
app:useCompatPadding="true" />
<android.support.v4.widget.NestedScrollView
android:id="@+id/nesterScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.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/food_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="12dp"
android:text="Food Name"
android:textColor="@color/colorPrimary"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/layout_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_search" />
<TextView
android:id="@+id/food_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:text="1,000"
android:textColor="@color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
android:id="@+id/number_button"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_marginBottom="18dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:backGroundColor="@color/colorAccent"
app:finalNumber="20"
app:initialNumber="1"
app:textSize="8sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<TextView
android:id="@+id/food_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:lineSpacingMultiplier="1.5"
android:padding="12dp"
android:text="description"
android:textColor="@android:color/black"
android:textSize="14sp" />
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<强> RESULT 强>