Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。

5
Intent和PendingIntent之间的区别
我通读了一些文章,两者似乎都做同样的事情,我想知道启动这样的服务有什么区别: Intent intent = new Intent(this, HelloService.class); startService(intent); 或类似的: Calendar cal = Calendar.getInstance(); Intent intent = new Intent(this, MyService.class); PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0); AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, pintent); 在我通读时,如果在服务中返回了参数START_STICKY,则这两个函数的作用相同。

8
为什么矢量可绘制比例没有按预期缩放?
我正在尝试在Android应用程序中使用矢量可绘制对象。从http://developer.android.com/training/material/drawables.html(重点是我): 在Android 5.0(API级别21)及更高版本中,您可以定义矢量可绘制对象,这些对象可缩放而不会丢失定义。 使用此可绘制对象: <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="@color/colorPrimary" android:pathData="M14,20A2,2 0 0,1 12,22A2,2 0 0,1 10,20H14M12,2A1,1 0 0,1 13,3V4.08C15.84,4.56 18,7.03 18,10V16L21,19H3L6,16V10C6,7.03 8.16,4.56 11,4.08V3A1,1 0 0,1 12,2Z" /> 这个ImageView: <ImageView android:layout_width="400dp" android:layout_height="400dp" android:src="@drawable/icon_bell"/> 尝试以400dp(在运行棒棒糖的大约2015年移动设备上较大的高分辨率)上显示图标时,产生此模糊图像: 将可绘制矢量的定义中的宽度和高度更改为200dp,可以显着改善400dp渲染大小时的情况。但是,将其设置为TextView元素的可绘制对象(即,文本左侧的图标)现在会创建一个巨大的图标。 我的问题: 1)为什么在矢量可绘制对象中有宽度/高度规范?我认为这些的全部目的是它们无损地进行缩放,从而使宽度和高度的定义毫无意义吗? 2)是否可以使用单个矢量可绘制对象,它在TextView上可作为24dp可绘制对象,但是可以很好地缩放以使用更大的图像?例如,如何避免创建多个不同大小的矢量可绘制对象,而是使用一个可按我的渲染要求缩放的矢量可绘制对象? 3)如何有效使用width / height属性,以及viewportWidth / Height有何区别? 额外细节: 设备正在运行API 22 将Android Studio …

13
如何重设Android Studio
我想重置Android Studio 0.2.13为默认状态。这意味着重置所有设置,删除所有项目,所有gradle文件,以便像全新安装一样工作。我必须遵循哪些步骤来实现这一目标?


6
什么是Jetifier?
什么是Jetifier?例如,要使用androidx打包的依赖项创建新项目,此新项目需要将以下行添加到gradle.properties文件中: android.enableJetifier=true 那是什么意思-“启用喷射器”?

8
如何在运行时在android中使文本加粗?
一个ListView在我的应用程序有很多字符串元素,如name,experience,date of joining,等我只是想name大胆。所有的字符串元素都将在一个中TextView。 我的XML: <ImageView android:id="@+id/logo" android:layout_width="55dp" android:layout_height="55dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:layout_marginTop="15dp" > </ImageView> <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/logo" android:padding="5dp" android:textSize="12dp" > </TextView> 我的代码来设置ListView项的TextView: holder.text.setText(name + "\n" + expirience + " " + dateOfJoininf);


30
会话“ app”:启动错误
在gradle构建完成的Android Studio 2.0更新之后,我得到以下信息: 会话“ app”:启动错误。 它阻止了该应用程序启动,但已安装在我的模拟器中。这是“运行”选项卡中显示的内容: 执行时发生意外错误:am start -n“ com.example.user.ypologismosmoriwn / com.example.user.ypologismosmoriwn.MainActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER启动活动时出错 这是代码: package com.example.user.ypologismosmoriwn; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } 这只是一个空的活动,没有添加任何内容 XML代码只是具有4个文本和3个复选框的相对布局 这是我得到的日志猫 谢谢任何愿意帮助的人

5
更新Studio 3.4后,无法为自变量找到方法leftShift()
将Studio 3.4和Gradle版本更新到5.1.1我后,由于找不到方法leftShift(),我在执行任务时遇到了错误 我的任务: task incrementBetaVersion << { println("Incrementing Beta Version Number...") incrementVersionNumber('BetaVersionNumber') println("Incrementing Beta Version Number...") incrementVersionName('BetaVersionName') } 我<<在行中出现了左移运算符的错误。 如何解决这个错误?

11
设置宽度以匹配ConstraintLayout中的约束
我想将视图的左右两侧限制为父视图的边距,并使其填充分配的空间。但是,将width设置为match_parent或wrap_content似乎会产生相同的结果。 是否有等同于match_constraints的东西(与match_parent和wrap_content相反)?难道match_parent和wrap_content影响布局还是他们在新的约束布局忽略? 为我最喜欢的平台爱上这个新的布局系统!

8
Android Room Persistence Library:Upsert
Android的Room持久性库优雅地包含适用于对象或集合的@Insert和@Update批注。但是,我有一个用例(包含模型的推送通知),由于数据库中可能存在或可能不存在数据,因此需要UPSERT。 Sqlite本身没有upsert,因此在SO问题中描述了解决方法。给定那里的解决方案,如何将它们应用于Room? 更具体地说,如何在Room中实现不会破坏任何外键约束的插入或更新?在onConflict = REPLACE上使用insert将导致onDelete调用该行的任何外键。在我的情况下,onDelete导致级联,而重新插入行将导致其他表中具有外键的行被删除。这不是预期的行为。

5
FrameLayout是做什么的?
我是编程新手。我使用的是Graphical Layout,然后在读取xml文件时,看到了FrameLayout。然后我搜索了,但是找不到有用的东西。什么是FrameLayout?它有什么作用?


22
布局中的布局<layout>在基本布局文件夹中没有声明[错误]
从Eclipse迁移到新版本的Android Studio 3.2,API 28之后,我的应用布局出现以下错误: 布局中的布局在基本布局文件夹中没有声明;在与该限定符不匹配的配置中查询资源时,这可能导致崩溃 我收到此错误的布局之一是: &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@null" &gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top|center_horizontal" android:adjustViewBounds="true" android:contentDescription="@string/hello_world" android:src="@drawable/loading_top" /&gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:adjustViewBounds="true" android:contentDescription="@string/hello_world" android:src="@drawable/loading_bottom" /&gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:contentDescription="@string/hello_world" android:background="@color/white" android:layout_marginBottom="5dp" android:paddingTop="10dp" android:paddingBottom="10dp" android:src="@drawable/loading_logo" /&gt; &lt;ImageView android:id="@+id/loading" …

6
如何更新React Native应用的版本号
我正在Android上使用React native。如何更新应用程序中的版本号?当我收到此错误。 我正在根据此URL https://facebook.github.io/react-native/docs/signed-apk-android.html生成文件 我曾尝试修改AndroidManifest.xml文件,但是在构建它之后,该文件会自动被修改回来。 &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.react" android:versionCode="1" android:versionName="1.0" &gt; 在这里,我修改了XML: &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.react" android:versionCode="2" android:versionName="1.1" &gt; 之后,构建文件会自动更改回。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.