在我的Android应用程序中,我有一个带导航抽屉的活动。我也在其中使用带有ImageView的CollapsingToolbarLayout,因为它还希望将图像作为工具栏的背景,在滚动后会折叠。 现在图像显示和完全关闭但工具栏不显示。我看不到打开导航抽屉或菜单按钮的按钮。这是我的布局文件:
activity_main.xml中
<android.support.v4.widget.DrawerLayout
mlns: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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/navigation_drawer_header"
app:menu="@menu/activity_main_drawer"
android:background="@color/navigation_view_background"
app:itemIconTint="@color/navigation_item_color"
app:itemTextColor="@color/navigation_item_color"/>
</android.support.v4.widget.DrawerLayout>
app_bar_main.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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="40dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<include
android:id="@+id/activity_description_header"
layout="@layout/fragment_edit_header"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.75" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
fragment_edit_header.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src = "@drawable/image"/>
</FrameLayout>
</layout>
答案 0 :(得分:1)
试试这个
<?php
if($layout=='default'){
$mediaCol = 'col-md-4';
$producInfoCol = 'col-md-5';
$slideBarCol = 'col-md-3';
}elseif($layout=='horizontal'){
$mediaCol = 'col-md-6';
$producInfoCol = 'col-md-6';
}elseif($layout=='vertical'){
$mediaCol = 'col-md-3';
$producInfoCol = 'col-md-6';
$slideBarCol = 'col-md-3';
}elseif($layout=='custom1'){
$mediaCol = 'col-md-12';
$producInfoCol = 'col-md-12';
}elseif($layout=='custom2'){
$mediaCol = 'col-md-7';
$producInfoCol = 'col-md-5';
}
?>
<div class="left-product col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="left-product-view row" itemtype="http://schema.org/Product">
<div class="product-img-box col-lg-5 col-md-5 col-sm-5 col-xs-12">
<?php echo $this->helper('mtfour')->getLabel($_product); ?>
<?php echo $this->getChildHtml('media') ?>
</div>
<div class="product-shop col-lg-7 col-md-7 col-sm-7 col-xs-12">
<div class="top-product-name">
<div class="product-name col-lg-9">
<h1 itemprop="name" style="text-transform:uppercase"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') . ' MOULDING'; ?></h1>
</div>
<div class="product-prev-next nav-wrapper col-lg-3 pull-right">
<ul>
<?php if($_prev): ?>
<li><a rel="prev" class="product-prev flex-prev left" title="<?php echo $this->escapeHtml($_prev->getName()); ?>" href="<?php echo $_prev->getProductUrl(); ?>"><i class="fa fa-angle-left"></i></a></li>
<?php endif; ?>
<?php if($_next): ?>
<li><a rel="next" class="product-next flex-next right" title="<?php echo $this->escapeHtml($_next->getName()); ?>" href="<?php echo $_next->getProductUrl(); ?>"><i class="fa fa-angle-right"></i></a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getChildHtml('extrahint') ?>
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<h2><?php echo $this->__('Quick Overview') ?></h2>
<div class="std" itemprop="description"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
</div>
<?php endif; ?>
<?php if (!$this->hasOptions()):?>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
<!--<span class="or"><?php //echo $this->__('OR') ?></span>-->
<?php endif; ?>
<?php endif; ?>
使用此主题
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
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"
tools:context="com.ncrypted.redfox.Activities.HomeClass">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolBar_hotel_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/img_hotel_home"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/redfox"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollNestedData"
android:layout_width="match_parent"
android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior">
// add here your other controls
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
如果有任何疑问,请询问我