小编Aje*_*ary的帖子

无论我尝试什么,AlertDialog 都不会包装内容

这是我的对话框的 xml 文件

<?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:id="@+id/main"
android:paddingTop="23dp"
android:background="@android:color/white">

<ImageView
    android:id="@+id/officer"
    android:layout_width="47dp"
    android:layout_height="47dp"
    android:layout_marginLeft="24dp"
    android:background="@drawable/officerman"/>
<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Are you sure you want\nto sign out?"
    android:textSize="15.5dp"
    android:textColor="#1C86FF"
    android:layout_marginTop="4dp"
    android:lineSpacingExtra="2dp"
    android:layout_marginLeft="84dp"/>

<LinearLayout
    android:layout_marginTop="20dp"
    android:layout_width="264dp"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1"
    android:layout_below="@id/officer">

    <Button
        android:id="@+id/yes"
        android:layout_width="wrap_content"
        android:layout_weight="0.5"
        android:layout_height="42dp"
        android:background="#1C86FF"
        android:text="Yes"
        android:textAllCaps="false"
        android:textSize="15dp"
        android:textColor="@android:color/white"/>

    <Button
        android:id="@+id/no"
        android:layout_width="wrap_content"
        android:layout_weight="0.5"
        android:layout_height="42dp"
        android:background="#0078FF"
        android:textSize="15dp"
        android:textColor="@android:color/white"
        android:textAllCaps="false"
        android:text="No"/>

</LinearLayout>

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

这是我的java代码

    AlertDialog.Builder build = new AlertDialog.Builder(Login.this);
    View lview = getLayoutInflater().inflate(R.layout.dialog_leave,null);
    build.setView(lview);
    AlertDialog dialog = build.create();
    dialog.show(); …
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog android-dialog

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

TextView FontSize根据不同的分辨率和ScreenSize

在这里,我开发了一个Android应用程序,可以在所有屏幕尺寸和分辨率设备上运行.但有一个问题是我的TextView'sFontsize在所有屏幕尺寸上都是相同的.我想FontSize根据不同ScreenSize和屏幕分辨率进行更改.

提前致谢.

android font-size textview

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

使用离子关闭应用程序时收到通知

我使用ionic2FCM.

我在应用运行时收到通知.

我需要在应用程序运行时收到通知.

我怎样才能做到这一点 ?

android ionic2 cordova-plugin-fcm

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

ConstraintLayout中的准则是否支持RTL

做指南ConstraintLayout支持RTL吗?我正在创建一个View右侧有个人资料图片和用户信息.我希望图片占用宽度的30%,而用户名和细节占70%.这是指南的有效用例吗?我知道其他实现,但我想知道是否可以在这里使用指南.我面临的问题是,在将设备语言更改为RTL语言后,指南仍保留在左侧的位置

截图

这是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:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:background="@color/colorPrimary"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24sp"
        tools:text="Full Name"
        app:layout_constraintTop_toTopOf="@+id/imageView"
        app:layout_constraintStart_toEndOf="@+id/guideline2" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="14sp"
        tools:text="Android Developer"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintStart_toEndOf="@+id/guideline2" />

    <android.support.constraint.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline2"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.30" />


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

android android-layout android-constraintlayout

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

使用标志 FLAG_ACTIVITY_NEW_TASK 启动活动,新活动不在新任务中

首先,我开始ActivityFLAG_ACTIVITY_NEW_TASK,然后使用命令“亚行外壳dumpsys Activity”,最后我发现在一个任务中的两项活动?

 Intent intent = new Intent(this, Main2Activity.class);
 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

这些Activity是正常的,我没有修改它们?这些是堆栈信息。

ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Display #0 (activities from top to bottom):
  Stack #1:
  mFullscreen=true
  mBounds=null
    Task id #2493
    mFullscreen=true
    mBounds=null
    mMinWidth=-1
    mMinHeight=-1
    mLastNonFullscreenBounds=null
    * TaskRecord{cb64df8 #2493 A=com.example.flag U=0 StackId=1 sz=2}
      userId=0 effectiveUid=u0a63 mCallingUid=2000 mUserSetupComplete=true mCallingPackage=null
      affinity=com.example.flag
      intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.flag/.MainActivity}
      realActivity=com.example.flag/.MainActivity
      autoRemoveRecents=false isPersistable=true numFullscreen=2 taskType=0 mTaskToReturnTo=1
      rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE
      Activities=[ActivityRecord{b786d24 u0 com.example.flag/.MainActivity t2493}, ActivityRecord{afe6f61 u0 com.example.flag/.Main2Activity t2493}]
      askedCompatMode=false inRecents=true …
Run Code Online (Sandbox Code Playgroud)

android

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

标签栏背景颜色没有改变

我是 React-Native 开发的新手。我正在使用' react-navigation '中的TabNavigator作为React-Native中的标签栏,除了标签栏activeBackgroundColor和inactiveBackgroundColor在android中没有改变外,一切正常。它只显示蓝色,如下图所示。

在此处输入图片说明

我使用的代码是:

import React, { Component } from 'react';
import { TabNavigator } from 'react-navigation';
import { PixelRatio } from 'react-native';

import { ColorScheme } from '../Resources/ColorScheme';
import {Fonts} from '../Resources/Fonts';

import TAB1 from '../Screens/TAB1'
import TAB2 from '../Screens/TAB2'
 /** */
 var FONT_SIZE = 8;
 if (PixelRatio.get() === 2) {
  FONT_SIZE=10
 }else if (PixelRatio.get() === 3) {
    FONT_SIZE=12
  }

export default FavoritesScreenTabNavigator=TabNavigator({
    TAB1:{screen:TAB1},
    TAB2:{screen:TAB2}
  },{
      tabBarPosition:'top',
      swipeEnabled:true,
      animationEnabled:true,
      tabBarOptions:{
          activeTintColor:ColorScheme.tabBarSelectedTintColor,
          inactiveTintColor:ColorScheme.tabBarUnSelectedTintColor,
          activeBackgroundColor:'white', …
Run Code Online (Sandbox Code Playgroud)

android jsx tabnavigator react-native react-navigation

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

RecyclerView 仅在某些项目之间添加分隔线

我想在我的RecyclerView Layout. 我已经搜索了一段时间,但我只能找到使用 的解决方案RecyclerView.addItemDecoration,它在所有项目之间添加了分隔线。我可以创建一个只有一行的布局并将其添加到RecyclerView,但这对我来说似乎不是一个优雅的解决方案。

android android-recyclerview

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

错误:包含非法的最终字段-Kotlin

我正在使用带有Realm,Gson注释的Kotlin数据类从服务器获取数据.

问题:当我在android studio中运行项目时,会出现以下错误

Error:Class "VenderConfig" contains illegal final field "name".
Run Code Online (Sandbox Code Playgroud)

我正在学习Kotlin,所以对此并不太了解.

我的VenderConfig班级是:

@RealmClass
class VenderConfig(
        @SerializedName("name")
        val name: String? = null,
        @SerializedName("website")
        val wb_url: String? = null,
        @SerializedName("icon")
        val icon: String? = null,
        @SerializedName("logo")
        val logo: String? = null,
        @SerializedName("description")
        val description: String? = null,
        @PrimaryKey
        @SerializedName("id")
        val id: Int? = null
) : RealmObject() {

}
Run Code Online (Sandbox Code Playgroud)

我也尝试使用字段打开关键字并删除数据关键字,但它没有解决问题.

android realm kotlin

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

AppCompatActivity与DaggerActivity

我只是有一个自定义Toolbar工作,然后试图在我的Android项目中获得Dagger2并且运行到我DaggerActivity没有延伸AppCompatActivity的教程我说过要使用.

即.我按照这些说明https://developer.android.com/training/appbar/setting-up.html

有没有办法同时使用它们?

谢谢,迪恩

android dagger-2

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

缓存图像而不显示滑行

是否可以使用滑行缓存图像而不在imageView?中显示它。如果是,那又如何?

现在,我正在执行以下代码:

Glide
  .with(getApplicationContext())
  .load("imageUrl")                
  .override(windowWidth(),(int)windowWidth()*0.5))
  .diskCacheStrategy(DiskCacheStrategy.ALL);
Run Code Online (Sandbox Code Playgroud)

但这是行不通的,当应用打开时,滑行不是从缓存而是从URL加载图像。

android caching android-glide

0
推荐指数
2
解决办法
2320
查看次数