我无法找到以下失真的根本原因.
UI工作正常但是当我将屏幕旋转到横向时,UI在滚动时会变形.
当屏幕再次旋转为纵向时,这种失真会继续.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/i_details" />
<include layout="@layout/v_details" />
<include layout="@layout/d_details" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
更新
i_details
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/colorPrimary">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:layout_margin="4dp"
android:text="Large Text"
android:textSize="25sp" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="4dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_margin="8dp"
android:text="Message"
android:textSize="14sp" />
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|start"
android:layout_margin="8dp"
android:text="RANDOM TEXT"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
v_details
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 我正在使用Java 8功能比较2个地图,并根据条件想要返回结果.使用.forEach显示编译时错误,基本上,返回是从Lambda表达式返回而不是从循环返回.如何从包围lambda的循环返回?
请注意,我没有比较两个地图对象的相等性
nMap.forEach((k,v) -> {
if (!mMap.containsKey(k) || mMap.get(k) < v) {
return -1;
}
});
Run Code Online (Sandbox Code Playgroud) 当键盘出现时,需要调整类似于Cordova/Phonegap的webview.现在根据下面的代码,我的输入文本字段被设备键盘覆盖.我想挤压webview的高度,并调整设备键盘上方的高度.
活动代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_home">
<include android:id="@+id/head" layout="@layout/header" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="11dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
android:layout_marginTop="2dp"
android:layout_below="@id/head"
android:background="@drawable/overlay_bg2"
android:orientation="vertical"
android:padding="9dp" >
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:isScrollContainer="true"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLargeInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible" />
</FrameLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
清单条目:
主题 android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
活动键盘控制 android:windowSoftInputMode="adjustResize"
这是我的第一个ROOM实现。我有一个User类,其中有一个Pets列表作为其成员变量之一。
public class User {
String id;
String name;
List<Pet> pets;
}
Public class Pets {
String id;
String type;
}
Run Code Online (Sandbox Code Playgroud)
如何通过以下JSON为Room Database创建其Entity和DAO类?
{
"users":[
{
"id":"as123",
"name":"John",
"pets":[
{
"id":"p123",
"type":"dog"
}
]
},
{
"id":"as343",
"name":"Mark",
"pets":[
{
"id":"p324",
"type":"dog"
},
{
"id":"p254",
"type":"cat"
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我创建了以下内容,但不确定如何创建正确的列或联接这些表。
实体类别
@Entity(tableName = "user")
public class User {
@PrimaryKey
@NonNull
@ColumnInfo(name = "id")
String id;
@Nullable
@ColumnInfo(name = "name")
String name;
List<Pets> pets; // …Run Code Online (Sandbox Code Playgroud) sqlite android android-database android-room android-architecture-components
我的团队正在使用 LiveData、BaseObservable(用于可绑定字段)和导航组件将现有的基于 MVC 的代码重新架构为 MVVM。
早些时候,我们将所有活动都以标头片段作为工具包,现在使用导航组件将单个活动与多个片段一起使用。我们正在重用标头片段,但它被放置在 Activity 内部,并且只有使用导航组件的 Activity 中的片段在其下方发生变化。
在片段 2 中,我们有一个带有隐藏布局的回收器视图。这些布局根据 BaseObservable 字段使用 xml 本身的数据绑定变得可见/消失。
辅助功能问题
之前使用对讲时一切正常。但是现在,当我们单击回收器视图中的某个项目并展开该项目并对子文本 1 执行单击操作时,新的子文本 2 变得可见,但无法保留辅助功能焦点。它的焦点持续几秒钟,然后焦点从回收器视图转移到标题图块,如图所示。这导致辅助功能对讲流程出现问题。
要求:子文本 2 应保留可访问性焦点。
子文本 2
旧代码的 onClickListener 中使用的代码片段
holder.subText2.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
Run Code Online (Sandbox Code Playgroud)
新代码
binding.subText2.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
binding.subText2.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它发挥作用并将可访问性焦点保留在子文本 2 上?
更新
添加以下代码后,它可以正常工作。但我想避免使用view.requestFocus(). 是否可以???
AccessibilityManager am = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE);
if(am.isEnabled()){
view.requestFocus();
view.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}
Run Code Online (Sandbox Code Playgroud) android accessibility android-databinding android-jetpack android-architecture-navigation
我已经按照
自定义PreferenceCategory标题
我设法获得相同的屏幕,但使用PreferenceFragment !!
我如何为PreferenceFragmentCompat V14做到这一点?
这是我的Code
Style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:listSeparatorTextViewStyle">@style/PreferenceStyle</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
<style name="PreferenceStyle" parent="@android:style/Widget.TextView">
<item name="android:textColor">@color/colorDialogPop</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/text_medium</item>
<item name="android:padding">@dimen/padding_large</item>
<item name="android:layout_marginLeft">@dimen/margin_medium</item>
<item name="android:background">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
preference.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/heading_general"
android:layout="@layout/settings_text">
<SwitchPreference
android:padding="@dimen/padding_medium"
android:title="@string/enable_push" />
<SwitchPreference
android:padding="@dimen/padding_medium"
android:title="@string/send_email" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/heading_account"
android:layout="@layout/settings_text">
<EditTextPreference
android:padding="@dimen/padding_medium"
android:title="@string/email" />
<EditTextPreference
android:padding="@dimen/padding_medium"
android:title="@string/name" />
</PreferenceCategory>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
setting_text.xml用于标题文本的布局
<TextView …Run Code Online (Sandbox Code Playgroud) android android-preferences android-layout android-fragments android-styles
我正在使用现有服务为Alexa Echo创建自定义技能。
该服务具有许多功能,可满足不同目的。
我希望我的技能能够服务于所有这些功能。
所有服务都是HTTPS POST服务,它接受JSON RAW主体请求并以JSON提供结果。
Q1。我是否可以像单独意图那样使用我的技能中的每个功能?
Q2。我应该使用Lambda还是可以直接使用我的服务?
Q3。如果使用Lambda,我可以构造所需的有效负载并将其发送到我的服务并获取并解析我的响应吗?
Q4。使用Lambda付费服务?
Q5。无需使用Lambda就能直接完成吗?如果是,怎么办?
Q6。 两种方法都有视频教程吗?
alexa aws-lambda alexa-skills-kit amazon-echo alexa-voice-service
我需要实现深层链接和URL后备,以防应用程序不存在.
我可以使用意图过滤器和URL方案打开我的应用程序,但在应用程序不存在时无法回退到我的URL.
这是我的代码
setTimeout(function() {
window.location =
"http://m.abcd.com";
}, 25);
window.location = "abcd://";
Run Code Online (Sandbox Code Playgroud)
abcd是intentfilter中提供的URL方案.
可能是什么问题?
刚刚将Nexus 5设备从Android Lollipop升级到Marshmallow.我正在尝试使用Android Studio的录制功能以及使用命令行adb shell命令来录制应用程序导航.
两种方式都显示错误,即文件(需要创建的视频文件)无法访问或只读.
我无法录制任何内容.单击RECORD或按enter开始录制时出现错误.
我需要在6.0中启用任何选项吗?
命令行 :
Abhinavs-MacBook-Pro:platform-tools abhinavtyagi$ ./adb shell screenrecord /test.mp4
Unable to open '/test.mp4': Read-only file system
Run Code Online (Sandbox Code Playgroud)
android screen-recording android-studio android-6.0-marshmallow
android ×7
alexa ×1
amazon-echo ×1
android-architecture-components ×1
android-architecture-navigation ×1
android-room ×1
aws-lambda ×1
cordova ×1
deep-linking ×1
fallback ×1
foreach ×1
java ×1
java-8 ×1
java-stream ×1
lambda ×1
sqlite ×1
webview ×1