我有一个带有 ImageView 的工具栏,该工具栏允许滚动和滑动。
我正在寻找一种方法来创建类似于 whatsapp 的个人资料的界面。
我需要能够点击工具栏内的 ImageView 并在弹出另一个界面(或 Activity )后允许保存或缩放图像(如 whatsapp 的个人资料图片)。
Google 提供了 ZoomView 但它还不够,我不需要只缩放图像,也许我需要创建另一个 Activity,我不知道从哪里开始
点击图片后得到的示例:
最佳答案
您需要将 Android Studio 与 Google Design 库一起使用, 它支持 - CoordinatorLayout,具有折叠工具栏布局 如下所示,
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="312dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
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/imgDetailView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="fitCenter"
android:layout_margin="@dimen/card_margin"
android:src="@mipmap/ic_launcher"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:title="Outlet Details"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="Outlet Details" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
并在 onCreatOptionsMenu 方法中设置带有菜单项的工具栏。
检查 ImageView 的点击事件和 ImageView 的点击事件 用另一个与上面相同的 fragment 更改内容。
关于Android 在工具栏中打开图像,例如 Whatsapp 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32416782/