小编Ate*_*res的帖子

我们如何在android中为imageview设置高度和宽度dp?

我想设置高度和宽度dpImageViewandroid系统中务实.

我怎样才能做到这一点?

android imageview

29
推荐指数
4
解决办法
5万
查看次数

高程不适用于协调器布局内的BottomSheet

我想BottomSheet在我的布局中使用a .根视图是一个CoordinatorLayout,我想设置Elevation在底部表格的顶部,所以我设置它的高值(50dp),但它没有显示应用程序运行时,但它出现在Android工作室设计工具.

我试图用纯色而不是渐变来设置工作表的背景,但它仍然可以工作.我也尝试使用阴影形状,但它没有提供相同的高程外观.

这是我的XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.atefhares.StartActivity"
    android:clipToPadding="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/DetailsView"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Details Should be shown here"
                android:id="@+id/textView"
                android:textSize="25sp"
                android:padding="20dp" />
        </LinearLayout>

        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="com.atefhares.Start_Activity" />


    </LinearLayout>
    <android.support.v4.widget.SlidingPaneLayout
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_peekHeight="70dp"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
        android:background="@drawable/gradiant"
        android:fillViewport="true"
        android:elevation="50dp">


        <include layout="@layout/bottom_sheet_layout"/>

    </android.support.v4.widget.SlidingPaneLayout>

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

编辑:bottom_sheet_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:orientation="vertical">


    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="@color/colorPrimary"
        android:padding="10dp"
        android:id="@+id/inviteLL"> …
Run Code Online (Sandbox Code Playgroud)

android elevation android-coordinatorlayout bottom-sheet

11
推荐指数
1
解决办法
3767
查看次数

如何在android中退出app时删除createTempFile创建的所有临时文件?

我使用以下代码创建一些临时文件,并将tem包装为inputteam以发送到客户端.

据我所知,当磁盘空间不足时,android系统可以自动删除临时文件.

但我希望当我退出应用程序时,我可以自己删除临时文件,我该怎么办?谢谢!

File outputDir = context.getCacheDir(); // context being the Activity pointer
File outputFile = File.createTempFile("prefix", "extension", outputDir);
Run Code Online (Sandbox Code Playgroud)

java android

11
推荐指数
2
解决办法
8784
查看次数

mobile:如何防止pull-to-refresh

如何防止Chrome android的Web应用程序中的pull-to-refresh?

我尝试了答案

禁用android的chrome pull-down-to-refresh功能

body {
  overflow-y: hidden;
}
Run Code Online (Sandbox Code Playgroud)

要么

body {
  touch-action: none;
}
Run Code Online (Sandbox Code Playgroud)

那没起效.任何人都有一个有效的解决方案?浏览器使用pull-to-refresh默认行为是非常糟糕的,对于Web应用程序来说这是非常不受欢迎的.

google-chrome pull-to-refresh

9
推荐指数
1
解决办法
2308
查看次数

ripple drawable在Android API 19上崩溃应用程序

我正在使用自定义波纹 drawable

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:exitFadeDuration="@android:integer/config_shortAnimTime"
    android:color="@android:color/white">

   <item android:id="@android:id/mask">
        <shape android:shape="rectangle" >
            <solid android:color="@android:color/white" />
        </shape>
   </item>


</ripple>
Run Code Online (Sandbox Code Playgroud)

但它崩溃了API 19上的应用程序

android.content.res.Resources$NotFoundException: File res / drawable /
    ripple_effect_square2.xml from drawable resource ID #0x7f02017d
at android.content.res.Resources.loadDrawable(Resources.java:2101)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.view.View.setBackgroundResource(View.java:15303)

Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line # 2: invalid drawable tag ripple
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java: 933)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java: 877)
at android.content.res.Resources.loadDrawable(Resources.java: 2097)
at android.content.res.Resources.getDrawable(Resources.java: 700) 
at android.view.View.setBackgroundResource(View.java: 15303) 
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能防止崩溃?

android rippledrawable android-api-levels

7
推荐指数
2
解决办法
6260
查看次数

有没有办法使用带有分区的 pandas to_parquet 覆盖现有数据?

我正在使用 pandas 使用带有分区的 to_parquet 函数编写镶木地板文件。例子:

df.to_parquet('gs://bucket/path', partition_cols=['key'])
Run Code Online (Sandbox Code Playgroud)

问题是每次我运行代码时。它会在分区中添加一个新的 parquet 文件,当您读取数据时,您会在每次运行脚本时获取所有数据。本质上,数据每次都会附加。

有没有办法在每次使用 pandas 写入时覆盖数据?

python pandas parquet

6
推荐指数
1
解决办法
2715
查看次数

第一次Git推送被拒绝

当我键入git push origin master以下错误消息从git显示:

To https://github.com/farrasdoko/RumahSakit.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/farrasdoko/RumahSakit.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

然后,i型git fetch origingit merge origin mastergit pull origin master 从GIT中所示的下面的错误消息:

From https://github.com/farrasdoko/RumahSakit …
Run Code Online (Sandbox Code Playgroud)

git version-control push github

5
推荐指数
1
解决办法
4247
查看次数

如何将ArrayList放入bundle中

我已经为这样的arraylist增加了一些价值:

    private List<InfoProduct> product;

    product = new ArrayList<>();
    product.add(new InfoProduct(R.drawable.cloth, Product_title, "0", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.guitar, Product_title, "1", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.cloth, Product_title, "2", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.guitar, Product_title, "3", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.cloth, Product_title, "4", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.guitar, Product_title, "5", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.cloth, Product_title, "6", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.guitar, Product_title, "7", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.cloth, Product_title, "8", Product_data2, lunch,R.drawable.cardview_circle_corner));
    product.add(new InfoProduct(R.drawable.guitar, Product_title, "9", Product_data2, lunch,R.drawable.cardview_circle_corner));
Run Code Online (Sandbox Code Playgroud)

当我需要去其他Fragment时,我想使用Bundle来传输我的ArrayList,所以我写了一些代码来遵守这个

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.fragment_youtube, new FragmentYoutubeProduct(), "youtube");
    ft.addToBackStack("youtube");
    Bundle bundle …
Run Code Online (Sandbox Code Playgroud)

java android arraylist

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

OpenJDK 1.8是否支持JFR?

我不确定OpenJDK1.8是否支持JFR(Java飞行记录器)。我知道它是在OpenJDKBug论坛上提出的。

OpenJDKLinux终端上使用on 并执行以下操作:

jcmd `<pid>` JFR.start 
Run Code Online (Sandbox Code Playgroud)

退货

java.lang.IllegalArgumentException:未知的诊断命令

java performance openjdk profiling

4
推荐指数
3
解决办法
4567
查看次数

以编程方式设置 FlexboxLayout 的属性 layout_wrapbefore

flexbox-layout包含TextView具有以下属性的内容:

app:layout_wrapBefore="true" 
Run Code Online (Sandbox Code Playgroud)

但我需要以false编程方式将其设置为!

关于如何做到这一点的任何想法?


xml,如果需要的话!

<com.google.android.flexbox.FlexboxLayout
        android:id="@+id/flexboxlayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        app:alignContent="stretch"
        app:alignItems="stretch"
        app:flexWrap="wrap"
        app:justifyContent="flex_end">


        <TextView
            android:id="@+id/mainText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="07:22 PM"
            android:textSize="12sp"
            app:layout_alignSelf="center"
            app:layout_wrapBefore="true" />

    </com.google.android.flexbox.FlexboxLayout>
Run Code Online (Sandbox Code Playgroud)

android android-flexboxlayout

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

无法解决猫鼬模型的循环依赖

我有 3 个模型,Book&& Author“类别”。作者可以拥有多本书。类别可以包含多本书,如果没有有效的作者或类别,则无法创建书籍

const schema = new mongoose.Schema(
  {
    title: dbHelpers.bookTitleValidation,
    image: dbHelpers.imageValidation,
    author: dbHelpers.bookAuthorValidation,
    category: dbHelpers.categoryValidation,
    reviews: [dbHelpers.bookReviewValidation],
    rates: [dbHelpers.bookRateValidation],
  },
  { timestamps: true }
);
Run Code Online (Sandbox Code Playgroud)

我想做的是:

  • 当尝试保存一本新书时,我应该验证关联的作者和类别是否有效,因此我创建了一个预“保存”中间件来验证这一点[在导出模型之前在图书模型中]。
  • 删除作者或类别时,应删除所有关联的书籍,因此我再次创建了一个预“删除”中间件来实现此目的[在导出模型之前在作者和类别模型中]。

Book这是模型中预“保存”的中间件

schema.pre("save", async function (next) {
  const author = await authorModel.findById(this.author);
  if (!author) {
    next(new Error("Author is not valid!"));
  }

  const category = await categoryModel.findById(this.category);
  if (!category) {
    next(new Error("Category is not valid!"));
  }

  next();
});
Run Code Online (Sandbox Code Playgroud)

这是Author模型中预“删除”中间件

schema.pre("remove", { document: true }, async …
Run Code Online (Sandbox Code Playgroud)

mongoose node.js express

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

Jekyll-即使使用手表也无法自动再生

运行以下任何命令时:

jekyll serve
bundle exec jekyll serve
bundle exec jekyll serve --watch
bundle exec jekyll serve --force_polling
Run Code Online (Sandbox Code Playgroud)

我得到:

自动再生:已禁用。使用--watch启用。

并且直到停止(ctrl + c)并再次运行命令,我才能看到本地更新!

jekyll版本(jekyll -v)给出jekyll 3.4.3了与我的相同gemfile

我应该怎么做才能观察变化?

ruby jekyll

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