小编Dra*_*ško的帖子

为什么FrameLayout没有在我的布局中正确设置Z顺序?

我有以下布局(这里提供了更简单的设计):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_main">
    <FrameLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        >
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hey, badge!"
            android:layout_margin="10dp"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="AAAAA"
            android:layout_margin="10dp"
            android:textSize="12sp"
            android:background="#ff00ff"
            android:padding="10dp"
            android:layout_gravity="top|end"
            />
    </FrameLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我希望将TextView设置为文本"AAAA"以充当Button的徽章,即将其放置在其右上角的按钮上,但事实并非如此.

相反,当我在带有Lollipop的HTC One M7或带有Lollipop的Genymotion Nexus 6上尝试此代码时,屏幕看起来像这样:

视图截图严重放置

当我使用KitKat在Genymotion Nexus 5上尝试相同的代码时,一切看起来都符合预期,即第一个视图(按钮)显示在徽章(textview)下面

有没有人知道这里有什么问题?

谢谢,Deveti

android android-layout android-framelayout

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

使用Java中的count()过滤领域

我正在使用最新的Realm(0.90.0)并且在一对多关系中有两个RealmObjects事件和游戏:

public class Event extends RealmObject
{
    ...
    private RealmList<Game> games;
}
Run Code Online (Sandbox Code Playgroud)

我希望过滤事件的条件之一,游戏数量必须大于0.我不知道如何在我的查询中包含该过滤器.

谢谢!

android count aggregate-functions realm

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

矢量可绘制显示为完整的圆圈

我有以下矢量可绘制:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="25dp"
    android:height="25dp"
    android:viewportWidth="25"
    android:viewportHeight="25">

    <path
        android:fillColor="#FFFFFF"
        android:fillType="evenOdd"
        android:strokeWidth="1"
        android:pathData="M12.5,25 C19.4035594,25 25,19.4035594 25,12.5 C25,5.59644063 19.4035594,0 12.5,0
C5.59644063,0 0,5.59644063 0,12.5 C0,19.4035594 5.59644063,25 12.5,25 Z M12.5,24
C18.8512746,24 24,18.8512746 24,12.5 C24,6.14872538 18.8512746,1 12.5,1
C6.14872538,1 1,6.14872538 1,12.5 C1,18.8512746 6.14872538,24 12.5,24 Z M16,6
C17.6568542,6 19,7.34226429 19,8.99878564 L19,16.0012144 C19,17.6573979
17.6534829,19 16,19 C14.3431458,19 13,17.6577357 13,16.0012144 L13,8.99878564
C13,7.34260206 14.3465171,6 16,6 Z M14,16.0012144 C14,17.1052262 14.8952058,18
16,18 C17.1026267,18 18,17.1036857 18,16.0012144 L18,8.99878564 C18,7.89477378
17.1047942,7 16,7 C14.8973733,7 14,7.89631432 14,8.99878564 L14,16.0012144 Z
M8.33473905,12.5 C8.14415114,12.3451212 7.57820716,11.8273213
7.57820716,11.8273213 C6.80306599,11.0695455 6,10.0347728 …
Run Code Online (Sandbox Code Playgroud)

svg android android-vectordrawable

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

如何在ConstraintLayout中使用固定边距和动态宽度均匀地放置视图?

我想像这样设置ConstraintLayout:

在此输入图像描述

我需要固定左右约束,尺寸尺寸比为1:1,宽度将是灵活的,它将调整到屏幕的实际宽度.我设置如下:

  1. 左右约束是8dp
  2. 这些视图的大小设置为"任意大小"
  3. layout_constraintDimensionRatio ="1:1"

我所拥有的是所有视图都被设置为点,除了设置左右约束(其他只有左约束)的视图.那个人应用了1:1的比例规则.

我该怎么做才能修复这个布局?

这是我尝试添加链的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="rs.agilesolutions.constraintlayouttest.MainActivity">

    <TextView
        android:id="@+id/textView"
        android:text="1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="16dp"
        style="@style/TextViewCustom"
        app:layout_constraintRight_toLeftOf="@+id/textView2"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintDimensionRatio="1:1" />

    <TextView
        android:id="@+id/textView2"
        android:text="2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintBaseline_toBaselineOf="@+id/textView"
        style="@style/TextViewCustom"
        app:layout_constraintRight_toLeftOf="@+id/textView3"
        app:layout_constraintLeft_toRightOf="@+id/textView"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintDimensionRatio="1:1" />

    <TextView
        android:id="@+id/textView3"
        android:text="3"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintBaseline_toBaselineOf="@+id/textView"
        style="@style/TextViewCustom"
        app:layout_constraintRight_toLeftOf="@+id/textView4"
        app:layout_constraintLeft_toRightOf="@+id/textView2"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintDimensionRatio="1:1" />

    <TextView
        android:id="@+id/textView4"
        android:text="4"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintBaseline_toBaselineOf="@+id/textView"
        style="@style/TextViewCustom"
        app:layout_constraintRight_toLeftOf="@+id/textView5"
        app:layout_constraintLeft_toRightOf="@+id/textView3"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintDimensionRatio="1:1" />

    <TextView …
Run Code Online (Sandbox Code Playgroud)

android android-constraintlayout

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

如何在我的自定义主题中设置EditText中的选择颜色?(机器人)

我创建了自定义主题,在我的布局中,我有几个EditText视图.自从我开始

android:selectAllOnFocus="true"
Run Code Online (Sandbox Code Playgroud)

,我注意到选择的颜色是我手机的默认颜色,所以我想知道我可以设置一些属性,当然,在我的主题定义中有一个想要的效果,即设置选择的颜色需要的颜色?

最好的,Deveti

customization android android-theme android-edittext

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

支持库26.0.0-beta2中的字体:错误:prolog中不允许使用内容

我正在尝试使用新功能,直接将字体添加到xml但没有运气.

我为26.0.0-beta2支持库设置了我的项目,在font文件夹中创建了资源文件res夹,将一些字体复制到它,当试图构建它时,我收到错误:prolog中不允许内容.信息.

这是结构:

在此输入图像描述

我的应用程序' build.gradle没什么特别的:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

ext {
    supportLibVersion = '26.0.0-beta2'
    constraintLayout = '1.0.2'
    playServicesVersion = '10.2.6'
    butterknifeVersion = '8.0.1'
    stethoVersion = '1.5.0'
    realmStethoVersion = '2.0.0'
    daggerVersion = '2.11'
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

我的模块build.gradle是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion …
Run Code Online (Sandbox Code Playgroud)

fonts android

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

Dart 扩展函数只有在调用它的同一个文件中时才可见

假设我创建了两个文件。首先,我创建一个扩展函数并从另一个文件中的类调用它。

文件date_extensions.dart

import 'package:date_format/date_format.dart';

extension on DateTime {
  String getSQLFriendly() => formatDate(this, ["yyyy", "-", "MM", "-", "dd", " ", "HH", ":", "mm", ":", "ss"]);
}

Run Code Online (Sandbox Code Playgroud)

和文件some_date_class.dart

import 'date_extensions.dart';

class SomeClassWithDate{

  DateTime dateTime;

  SomeClassWithDate(this.dateTime);

  toString() => dateTime.getSQLFriendly();

}
Run Code Online (Sandbox Code Playgroud)

现在,我收到一个错误:

lib/test/some_date_class.dart:9:26: Error: The method 'getSQLFriendly' isn't defined for the class 'DateTime'.
 - 'DateTime' is from 'dart:core'.
Try correcting the name to the name of an existing method, or defining a method named 'getSQLFriendly'.
  toString() => dateTime.getSQLFriendly();
Run Code Online (Sandbox Code Playgroud)

现在,当我将扩展函数放在我调用它的同一个文件中时,一切正常。

这是错误,功能还是我做错了什么?我希望后者是答案。:)

extension-methods dart flutter

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

如何在Alfresco 4的前端访问后端的代码?

我希望在整个Alfresco(后端和前端)中提供可以访问的classess和enums.我怎样才能做到这一点?

感谢:D

alfresco alfresco-share

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

为什么三元运算符在Kotlin中没有"工作"?

我有以下声明:

val visibility = if (itemView.img_playstore.visibility == View.VISIBLE)  View.GONE else View.VISIBLE
Run Code Online (Sandbox Code Playgroud)

而另一个:

val visibility : Int = itemView.img_playstore.visibility == View.VISIBLE ?  View.GONE : View.VISIBLE
Run Code Online (Sandbox Code Playgroud)

第一个是好的,但对于第二个,我收到以下消息:类型不匹配.必需的国际 找到布尔值.

这是什么原因?

kotlin

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