小编Joa*_*huk的帖子

在键盘上方显示Android SnackBar?

是否可以在键盘上方显示Android Snackbar(如Y坐标,而不是分层)?如果显示键盘,Snackbar当前会被隐藏,这是一种不受欢迎的行为.

android android-snackbar

57
推荐指数
4
解决办法
1万
查看次数

折叠工具栏布局,工具栏中包含徽标,标题,副标题

第一张图片 第二张图片 第三张图片

我希望这样做,但使用折叠工具栏布局或滚动后在工具栏中显示徽标和标题.

    <!-- Toolbars -->
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/detail_backdrop_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp"
        android:fitsSystemWindows="true">

        <ImageView
            android:id="@+id/background_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@drawable/background_1"
            app:layout_collapseMode="parallax"
            android:fitsSystemWindows="true"/>

        <RelativeLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

            <ImageView
                android:id="@+id/avatar_image"
                android:layout_width="@dimen/circular_image_avatar"
                android:layout_height="@dimen/circular_image_avatar"
                android:gravity="center"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_placerholder"
                android:layout_centerVertical="true"
                android:layout_centerHorizontal="true"
                android:transitionName="image_toolbar"/>

            <TextView
                android:id="@+id/profile_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Name title"
                android:textAlignment="center"
                android:layout_marginTop="@dimen/item_padding_top_bottom"
                android:gravity="center"
                style="@style/titleText_toolbar"
                android:layout_below="@+id/avatar_image"
                android:transitionName="title_toolbar"/>
            <TextView
                android:id="@+id/profile_subtitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Subtitle"
                android:textAlignment="center"
                android:gravity="center"
                style="@style/captionText_toolbar"
                android:layout_below="@+id/profile_title" />

        </RelativeLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_height="?attr/actionBarSize"
            android:layout_width="match_parent"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin">

            <!-- avatar image and title, subtitle -->

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.CollapsingToolbarLayout> …
Run Code Online (Sandbox Code Playgroud)

android toolbar android-layout material-design android-collapsingtoolbarlayout

38
推荐指数
1
解决办法
4万
查看次数

我希望我的RecyclerView不回收一些物品

我在RecyclerView内部使用异构视图,如本教程中所示.

我在RecyclerView里面有一些物品也是RecyclerViews.难以想象?假设我要复制Play商店的布局:一个具有垂直线性布局的大型RecyclerView,并由许多元素填充:单个应用程序和应用程序轮播.

如果要添加的项目是单个应用程序的布局,则将使用ID 1,我将添加单个项目的布局.另外,如果我需要添加一个Carousel,那么我将在主RecyclerView中添加一个元素:另一个带有自己的适配器的RecyclerView.

这非常有效.滚动主RecyclerView时除外.为什么?因为某些视图在不再可见时被销毁,然后在onBindViewHolder()方法中重新创建.为什么在这?因为主RecyclerView的适配器正在传递位置X然后调用OnBindViewHolder().然后,后者使用自己的适配器创建一个新的RecyclerView并将其分配给它.我想保留这些观点只是因为它们每次重新充气都很重要.

这可能吗?如果是的话,你能告诉我怎么样吗?

android android-layout android-recyclerview

28
推荐指数
5
解决办法
3万
查看次数

带有打字稿的Firebase 3.0

我正在尝试按照谷歌提供的指导方针开发一个带有angular2和firebase 3.0身份验证的Web应用程序.但是,所有Web指南都有javascript示例.

我在index.html中添加了以下行

<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
var config = {
   apiKey: "AIzaSyCSfBMvAdEDpcm-z6gWp2XXXXXXXXXXXXX",
   authDomain: "fototrans-calculator.firebaseapp.com",
   databaseURL: "https://fototrans-calculator.firebaseio.com",
   storageBucket: "fototrans-calculator.appspot.com",
};
firebase.initializeApp(config);
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用时

rootRef = firebase.database.ref();
Run Code Online (Sandbox Code Playgroud)

我在'firebase'上说错了

[ts] Cannot find name 'firebase'.
Run Code Online (Sandbox Code Playgroud)

现在我记得我已经使用以前版本的Firebase的打字安装了firebase.对于新版本的Firebase,我们是否还有这样的东西?请指导.

提前致谢

firebase typescript firebase-authentication

23
推荐指数
2
解决办法
1万
查看次数

在 Jetpack Compose 中使用自定义视图

假设我正在使用一些旨在提供一些 UI 小部件的库。假设这个库提供了一个名为 的按钮小部件FancyButton

另一方面,我有一个使用 Android Studio 4 创建的新项目,它允许我创建一个带有Empty Compose Activity.

问题是: 我应该如何将它添加FancyButton到视图堆栈中?是否可以?或者,对于 Jetpack Compose,我只能使用专为 Jetpack Compose 开发的组件。在这种情况下,据我所知,我只能使用Android组件执行标准(TextMaterialTheme,等)。

如果我尝试使用这样的东西:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
        MaterialTheme {
            Greeting("Android")
            FancyButton(context, "Some text")
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我收到这个错误:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath.

android android-jetpack-compose

4
推荐指数
2
解决办法
2960
查看次数

动画如何隐藏ActionBar并保留标签?

在Google Play商店应用的第5版中,滚动到内容,按下滚动操作栏,但选项卡已修复以显示在顶部.

这该怎么做?

在滚动之前

在此输入图像描述

滚动后

在此输入图像描述

android android-animation android-viewpager android-actionbar

3
推荐指数
1
解决办法
6570
查看次数

Android Studio - 重新启用标记为"不再显示"的弹出窗口

我是Android Studio v1.0.2及其SVN功能的用户.

在使用SVN项目并添加新文件时,Android Studio用于显示弹出窗口,询问我是否要安排文件以进行添加.我曾经打过NO,直到有一天我把"不再显示".

现在我需要该功能,因为我不喜欢手动将ADD添加到项目中的每个新文件.

没有删除所有配置有没有修复?

ide android android-studio

3
推荐指数
1
解决办法
744
查看次数

检查字符串是否以正则表达式中的点后两位数字结尾?

我正在尝试使用正则表达式测试字符串是否以 Java 中的点后的两位数结尾。怎样才能做到这一点?

像“500.23”这样的东西应该返回真,而“50.3”或“50”应该返回假。

我尝试过类似的事情,"500.00".matches("/^[0-9]{2}$/")但它返回 false。

java regex string

0
推荐指数
1
解决办法
4496
查看次数