android-intent 相关问题

关于实际和高级使用Intent,Intent Extras和Pending Intents以启动活动,服务或通过BroadcastReceiver响应系统或应用程序事件/通知的问题。 (参考基本熟悉信息)

Android 在视图之间绘制水平线

我的布局如下: 我的布局如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Twitter Feeds" android:textStyle="bold" /> <ListView android:id="@+id/list" android:layout_width="350dp" android:layout_height="50dp" /> <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> </LinearLayout> 我的要求是在TextView和ListView之间画一条水平线 有人可以帮忙吗? 它将在 TextView 和 ListView 之间绘制银灰色线 <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:background="#c0c0c0"/> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> 您应该使用新的轻量级视图Space来绘制分隔线。 如果您使用 Space 而不是 View,您的布局加载速度会更快。 水平分隔线: <android.support.v4.widget.Space android:layout_height="1dp" android:layout_width="match_parent" /> 垂直分隔线: <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" /> 您还可以添加背景: <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> 使用示例: .... <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="One"/> <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Two"/> <android.support.v4.widget.Space android:layout_height="match_parent" android:layout_width="1dp" android:background="?android:attr/listDivider"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Three"/> .... 为了使用Space,您应该在build.gradle中添加依赖项: dependencies { compile 'com.android.support:support-v4:22.1.+' } 文档https://developer.android.com/reference/android/support/v4/widget/Space.html 在布局中要分离的视图之间添加类似的内容: <View android:id="@+id/SplitLine_hor1" android:layout_width="match_parent" android:layout_height= "2dp" android:background="@color/gray" /> 希望有帮助:) 创建一次并在需要的地方使用它是一个好主意。 将其添加到您的 styles.xml 中: <style name="Divider"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">1dp</item> <item name="android:background">?android:attr/listDivider</item> </style> 并将其添加到需要行分隔符的 xml 代码中: <View style="@style/Divider"/> 最初由 toddles_fp 回答这个问题:Android Drawing Separator/Divider Line in Layout? 试试这个 <View android:layout_width="match_parent" android:layout_height="2dp" android:background="?android:attr/listDivider"/> 多年之后,终于有一个合适的视图可以在 XML 布局上显示分隔符/分隔线/水平线。为 Android 开发 Material Components 的团队已发布版本 1.5.0-alpha01,其中添加了 MaterialDivider 类。这允许向布局添加分隔线,如前所述。 首先,在 build.gradle 中添加以下内容: implementation 'com.google.android.material:material:1.5.0-alpha01' 然后,在 XML 布局上您可以编写: <com.google.android.material.divider.MaterialDivider android:layout_width="match_parent" android:layout_height="wrap_content"/> 瞧,你有一个分隔器。如果你想自定义分隔线的颜色,有一个xml属性:app:dividerColor。此视图还允许通过样式设置主题。欲了解更多信息,您可以查看此链接。 <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="2dp" android:background="#000000" /> 对 Bhoomika 接受的答案进行了改进,以获得更精美的外观: <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black" android:alpha="0.1"/> android:alpha 用于设置视图的不透明度。 您可以将此视图放在您的视图之间来模仿线条 <View android:layout_width="fill_parent" android:layout_height="2dp" android:background="#c0c0c0"/> 试试这个对我有用 <View android:layout_width="1dp" android:layout_height="match_parent" android:background="@color/tw_composer" /> 创建水平线 如果您正在使用 TextView,然后您想放置一行,则使用 View 这样你就可以使用任何颜色,如蓝色、红色或黑色提及背景颜色。 <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black"></view> 在您希望组件之间有分隔线的每个父级 LinearLayout 中,添加 android:divider="?android:dividerHorizontal" 或 android:divider="?android:dividerVertical。 根据您的LinearLayout的方向在它们之间选择合适的。 据我所知,这个资源样式是从Android 4.3开始添加的。 试试这个 <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/darker_gray"/> ---->简单的一个 <TextView android:layout_width="match_parent" android:layout_height="1dp" android:background="#c0c0c0" android:id="@+id/your_id" android:layout_marginTop="160dp" /> 可以指定背景颜色的视图(高度=几个 dpi)。 查看真实代码,它是: <LinearLayout android:id="@+id/lineA" android:layout_width="fill_parent" android:layout_height="2dp" android:background="#000000" /> 请注意,它可以是任何类型的 View。 如果您不想仅使用额外的视图来显示下划线。在您的 textView 上添加此样式。 style="?android:listSeparatorTextViewStyle" 缺点是它会添加额外的属性,例如 android:textStyle="bold" android:textAllCaps="true" 您可以轻松覆盖它。 对我有用的是 <view android:layout_below="@+id/kaimla_number" android:layout_width="match_parent" android:layout_height="3dp" android:background="@color/golden"></view> <view android:id="@+id/blackLine" android:layout_width="match_parent" android:layout_height="1dp" android:background="#000000" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"/> 应用程序:layout_constraintStart_toStartOf =“父”/> 使用此视图标签,您可以水平或垂直地创建视图,只需更改高度和宽度即可使其水平和垂直。您可以简单地创建水平和垂直线。 这是水平线代码,其中视图的高度是线的厚度。 <View android:id="@+id/view" android:layout_width="match_parent" android:layout_height="1.5dp" android:layout_marginHorizontal="24dp" android:layout_marginTop="20dp" android:background="@color/green" app:layout_constraintTop_toBottomOf="@id/imgChoice" />

回答 19 投票 0

需要在 Android 中伪造正在扫描的 NFC 标签

好的,我有一个应用程序。此应用程序仅在扫描 NFC 标签(任何标签)时才会完成任务。唯一的问题是,我没有任何 nfc 标签。无论如何,我正在努力消除对卡的需要,所以我...

回答 2 投票 0

回收器视图仅显示一件物品

我正在尝试使用回收器视图将数据写入文件,数据正在传递,但是一旦新数据传递,它就会被新数据覆盖,而它应该显示新数据并且......

回答 1 投票 0

为什么在启动action调用时多了一个onPause onResume?

我有一个简单的设置,可以启动拨号器以使用 ACTION_CALL 进行呼叫 覆盖 fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) 设置内容...

回答 1 投票 0

我无法将意图用于另一个活动,每次我都有空,问题出在哪里?

`在此输入图片描述 在此输入图像描述 在此输入图像描述 在 AuthActivity 中创建 userLogin,如果我们可以进行身份验证,我会在 BasketActivity 中发送我的登录信息,我想做我的

回答 1 投票 0

选择可以发送文本的应用程序(Whatsapp、Viber 和默认短信应用程序)Android

我的解决方案可以在三星设备上正常工作,但在小米设备上Whatsapp会自动启动。我希望用户选择从哪个应用程序发送一些提供的文本。 这段代码是正确的

回答 1 投票 0

如何在 kotlin 中使用意图发送值

Login.setOnClickListener(View.OnClickListener { val id = ID.getText().toString() val pw = Password.getText().toString() val 响应监听器 = 响应.监听器<

回答 1 投票 0

在多个对话流意图中添加训练短语时出现问题,有多个帐户

今天我们遇到了对话流问题。 我们尝试在来自不同帐户的多个对话流意图中添加训练短语,但没有应用更改。出现代理消息...

回答 1 投票 0

什么是 START_STICKY、START_NOT_STICKY 和 START_REDELIVER_INTENT 服务

我无法理解 START_STICKY, START_NOT_STICKY 和 START_REDELIVER_INTENT 谁能用例子解释清楚。 我浏览了这个链接,但无法清楚地理解它。

回答 3 投票 0

如何在 Android 上通过二维码启动 Web AR

给定 GLTF(或 GLB)资产,人们可以通过以下 URL 在 Android 手机上启动 WebAR 体验: intent://arvr.google.com/scene-viewer/1.0?file=&title=MyWebArAsset&

回答 1 投票 0

隐式意图:将图片从图库分享到我的应用程序

我试图让图库应用程序将图像共享到我的应用程序,问题是我不知道如何获取图库发送给我的图像数据。我假设我可以在方法.g中找到数据...

回答 1 投票 0

BroadcastReceiver 中 onReceive 方法中的意图 null 的额外内容

我有一个问题,我正在尝试设置 Android 通知,但是当我安排带有额外内容的意图时,额外内容会显示为空。 我创建意图和待处理意图的代码...

回答 1 投票 0

如何使用意图(Android TV)打开谷歌搜索键盘?

我想在我的 Android TV 应用程序上打开 Google 键盘搜索布局,因为它是由默认的 Android 启动器提供的。如下图所示。 单击此按钮后,它将打开页面...

回答 2 投票 0

getParcelableArrayListExtra 会导致将不同的类型设置为变量

问题始于当我们尝试将 getParcelableArrayListExtra 设置为变量时,它不支持类型检查。让我尽可能举一个基本的例子。 用户类。 导入 kotlinx.parcelize。

回答 3 投票 0

如何从Android 11服务启动Activity

如何从我的服务在后台打开活动? 该应用程序在后台运行,并且有一个 Intent Brodcast 触发我的应用程序中活动的启动。 我在 Android 上尝试过...

回答 2 投票 0

SAF:找不到处理意图的活动 - android.intent.action.OPEN_DOCUMENT_TREE - Android 13

刚刚更新了应用程序,该应用程序现在仅适用于 SAF,因此用户可以选择他们想要的任何目录,并且应用程序不仅可以处理媒体文件(MediaStore 是一个无用的东西)。 但兴趣...

回答 1 投票 0

使用Intent.ACTION_OPEN_DOCUMENT_TREE时的起始路径

使用 Intent.ACTION_OPEN_DOCUMENT_TREE 时是否可以指定“起始路径”? 当我这样使用它时: 意图 selectFolderIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);

回答 2 投票 0

如何使用相机Intent在不预览的情况下拍照?

我正在使用以下代码使用相机意图在服务中拍照 意图intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | 意图。

回答 3 投票 0

在某些设备上 ACTION_OPEN_DOCUMENT_TREE 不显示选择器

我使用 ACTION_OPEN_DOCUMENT_TREE 来允许用户选择路径并获得 SAF 权限,但在某些用户设备上意图 ACTION_OPEN_DOCUMENT_TREE 会导致类似这样的消息 没有可用的应用程序...

回答 1 投票 0

如何启动Android应用程序管理器

有谁知道android上应用程序管理器的包名称。我有一个方法,我想允许用户直接从我的应用程序转到应用程序管理器: 公共空间

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.