小编pul*_*ion的帖子

为什么Android上的每个应用程序都有单独的VM(Dalvik/ART)实例?

正如标题所述,
为什么Android上的每个App都有单独的VM(Dalvik/ART)实例?(需要它)

如果Android操作系统选择了单个虚拟机运行所有应用程序的模型,会发生什么?

android virtual-machine dalvik vm-implementation

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

为什么我的 DialogFragment 没有显示自定义布局?

我想显示一个DialogFragment没有标题、按钮等(即,典型对话框中不包含任何内容)而只是ProgressBar一个普通背景上的微调器。对于一个粗略的想法,背景的宽度与父元素的宽度相匹配,并且微调器位于它的中心。为此,我有一个自定义布局如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <View
        android:id="@+id/search_progress_alpha_indicator"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toTopOf="@+id/guideline3"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline2"
        android:background="#00ffffff"/>

    <ProgressBar
        android:id="@+id/search_tutors_progress_bar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:visibility="gone"/>

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline2"
        app:layout_constraintGuide_percent="0.20"
        android:orientation="horizontal"
        tools:layout_editor_absoluteY="126dp"
        tools:layout_editor_absoluteX="0dp" />

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline3"
        app:layout_constraintGuide_percent="0.80"
        android:orientation="horizontal"
        tools:layout_editor_absoluteY="378dp"
        tools:layout_editor_absoluteX="0dp" />


</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

这是应该在其上旋转View的背景ProgressBar

但是当我在 中膨胀这个布局时DialogFragment,它显示了完全不同的东西:

在此处输入图片说明

这是DialogFragment代码:

public static class SearchIndicatorDialogFragment extends DialogFragment{

        public static String FRAGMENT_TAG …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-dialogfragment

7
推荐指数
3
解决办法
5521
查看次数

Android 中的“scrim”是什么?

我正在阅读官方 Android Developers 上的博客文章,发现了这一段:

NavigationView 会为您处理状态栏的稀松布保护,确保您的 NavigationView 在 API21+ 设备上与状态栏正确交互。

在 SO 上找到了另一个答案,用文字说明,

Scrim:隐藏或遮蔽某物的东西。

因此,尽管我通常像理解句子一样理解上述答案,但在 Android 视图和布局的情况下,我无法将其可视化。

那么,谁能提供一个直观的例子来解释通俗的说法,究竟是什么?

android android-layout

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

如何将多个 SHA1 指纹添加到我的 Android 应用程序进行测试?

我的 Android 应用程序已经在 Google 开发人员控制台上有一个 SHA1 指纹,该指纹由另一位开发人员一段时间前生成。现在,我正在调试应用程序中的 Google Sign-in 错误,结果发现 Google Sign in 使用.android/debug.keystore在 OAuth 身份验证过程中找到的默认 SHA-1发出请求。我昨天生成了一个新的调试密钥,因为毕竟它是调试。

如何将这个新的调试密钥添加或合并到 Google 的开发者控制台以成功登录请求?(我不想替换旧密钥)

android google-signin android-app-signing

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

严重的Android Studio更新问题

我一直在使用Android Studio 1.1版.在2-3天之前,它要求更新到1.2.我以为它会变得更好.但是,现在我面临以下问题:

Warning:The project encoding (windows-1252) does not match the encoding specified in the Gradle build files (UTF-8).
This can lead to serious bugs.
<a href="http://tools.android.com/knownissues/encoding">More Info...</a><br><a href="open.encodings.settings">Open File Encoding Settings</a>
Run Code Online (Sandbox Code Playgroud)

和,

This version of the rendering library is more recent than your version of Android Studio. Please update Android Studio
Run Code Online (Sandbox Code Playgroud)

我已尝试卸载 - 重新安装它已经7次,但问题不会消失.我从来没有弄乱Android Studio设置.

为什么会这样?我该怎么做才能解决它?我只是非常绝望,我将格式化我的电脑,但这是一个庞大的任务,所以我在这里问.

PS:我尝试改变编码但没有任何作用.谢谢.

编辑1:遵循Sandspy的建议build.gradle包含以下内容,没有支持库.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.mankum93.geoquiz"
        minSdkVersion 15 …
Run Code Online (Sandbox Code Playgroud)

android auto-update android-studio

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

android:launchMode和android:documentLaunchMode属性之间有什么区别?

因此,我一直在阅读“ 任务”,“后退堆栈”和“概述屏幕”上的文档,有一件事使我感到困惑。在launchMode这里阅读之后documentLaunchModehttp : //developer.android.com/guide/components/tasks-and-back-stack.html然后在这里阅读:http : //developer.android.com/guide/components/recents.html我无法分辨它们之间的差异!

两者都被描述为提供控制相对于当前任务(启动活动的任务)的任务中新活动的启动的方法。那么这两种模式有何不同?-document的附加意味着什么?

以下是直接在清单文件中使用它们的文档:
LaunchMode: http : //developer.android.com/guide/topics/manifest/activity-element.html#lmode
DocumentLaunchMode: http : //developer.android。 com / guide / topics / manifest / activity-element.html#dlmode

android android-activity android-task

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

如何将我的 TextView 与 ConstraintLayout 中的 2 个其他视图对齐?

我一直在使用 ConstraintLayout 一段时间,到目前为止一直喜欢它,但遇到了布局对齐的问题。这是我所拥有的:

在此处输入图片说明

您会看到TextView文本Requested time,我希望此视图始终对齐LinearLayout即在其上方)下方以及右侧的评级栏下方。为此,我已将其上锚点锚定到 LinearLayout,但似乎无法将其限制为在右侧的评级栏下方对齐。我的意思是,我只能为每条边设置一个约束,对吗?

请注意,我也无法对LinearLayout始终大于或小于(图像视图 + 评分栏)的高度做出任何假设。因此,两者更深入的观点应该是Requested time的最终位置的决定因素 TextView

供您参考,这里是上面的布局文件:

<?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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="4dp"
    android:layout_marginBottom="4dp"
    android:layout_marginLeft="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginEnd="8dp"
    android:background="@color/lightGrey"
    android:id="@+id/constraintLayout">


    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/guideline"
        android:layout_marginRight="8dp"
        android:layout_marginEnd="8dp"
        app:layout_constraintHorizontal_bias="0.0"
        android:id="@+id/linearLayout"
        tools:layout_editor_absoluteY="16dp">

        <TextView
            android:text="@string/tutor_name"
            android:textStyle="bold"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tutor_name"/>

        <TextView
            android:text="@string/tutor_skill_set"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:id="@+id/skill_set"/>

        <TextView
            android:text="@string/tutor_types"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:id="@+id/tutor_types" />

        <TextView
            android:text="@string/tutor_location"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-constraintlayout

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

New Date()对象给出相同的值

我有一些代码利用Date对象作为文件的名称,以便每次都有不同的文件名,但奇怪的是新的Date对象toString()为每个循环迭代发出相同的内容.我的意思是,以下内容:

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String fileName = sdf.format((d = new Date())) + ".jpg";

Log.d("Date", d.toString());
Run Code Online (Sandbox Code Playgroud)

在循环中执行.

旁注:由于这与Java API有关,我没有将问题标记为Android的问题,但执行此代码的操作系统是Android.

据我所知,new Date()使用System.currentTimeMilis()的初始化值,可能是什么原因,这种不寻常的行为?

java date

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

复杂的指针表达式

我一直在阅读C++ vol1中的Thinking,并且有一个名为Complicated声明和定义的部分描述了以下表达式,我无法理解:

void * (*(*fp1)(int))[10];
float (*(*fp2)(int,int,float))(int);
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释表达式的含义,以及如何解决这些表达式?

布鲁斯给出的解释如下:

fp1 是一个指向函数的指针,该函数接受一个整数参数并返回一个指向10个void指针数组的指针.

fp2是一个指向函数的指针,该函数接受三个参数(int, int, and float)并返回一个指向函数的指针,该函数接受一个整数参数并返回一个float

虽然我已经发布了正确答案,但如果有人能够逐步演示这些表达式的解码,我将不胜感激.

c++ pointers function-pointers

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

将 RecyclerView 内的 RelativeLayout 向右对齐

当您与某人聊天时,我正在尝试开发类似 Activity 的 Whatsapp。我已经能够创建如下内容:

在此处输入图片说明

此处的聊天消息有 2 种类型 - 已发送和已接收。我希望收到的消息在左侧,发送的消息在右侧。为此,我创建了一个带有 LinearLayoutManager 的 RecyclerView 左侧和右侧对齐的以下布局:

接收消息的布局,即显示在左侧。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/message_view_border">

    <!--The message text-->
    <TextView
        android:id="@+id/message_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"/>
    <!--the timestamp-->
    <TextView
        android:id="@+id/time_stamp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/message_content"
        android:textStyle="bold"/>

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

已发送消息的布局,即显示在右侧。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:background="@drawable/message_view_border"
    android:layout_marginRight="8dp"
    android:layout_marginTop="8dp"
    android:layout_gravity="right"
    android:gravity="right">

    <!--The message text-->
    <TextView
        android:id="@+id/message_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"/>
    <!--the timestamp-->
    <TextView
        android:id="@+id/time_stamp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/message_content"
        android:textStyle="bold"/>

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

问题:正如您在图像中看到的,右侧显示的消息(带有文本“rtdfg”)没有这样做。我不明白,为什么即使在相对布局上将 layout_gravity 设置为正确之后它也不会这样做。

任何人都可以阐明为什么会发生这种情况以及如何将其与右侧对齐?

编辑 …

android android-layout

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