这篇文章主要围绕android–OrientationEventListener(TabletvsMobile)90度差异展开,旨在为您提供一份详细的参考资料。我们将全面介绍android–Orien
这篇文章主要围绕android – OrientationEventListener(Tablet vs Mobile)90度差异展开,旨在为您提供一份详细的参考资料。我们将全面介绍android – OrientationEventListener(Tablet vs Mobile)90度差异,同时也会为您带来ActivitiException: Activiti database problem: Tables missing for component(s) identity、android Drawable – getConstantState.newDrawable()vs mutate()、android – ChildEventListener和ValueEventListener Firebase接口有什么区别?、android – firebase的addValueEventListener()和addListenerForSingleValueEvent()之间的区别的实用方法。
本文目录一览:- android – OrientationEventListener(Tablet vs Mobile)90度差异
- ActivitiException: Activiti database problem: Tables missing for component(s) identity
- android Drawable – getConstantState.newDrawable()vs mutate()
- android – ChildEventListener和ValueEventListener Firebase接口有什么区别?
- android – firebase的addValueEventListener()和addListenerForSingleValueEvent()之间的区别
android – OrientationEventListener(Tablet vs Mobile)90度差异
我正在使用的活动有相机,所以我无法在方向之间切换,因此我使用Orientation的值根据需要在屏幕上重新定位几个元素.
是否可以检测设备是否是平板电脑,以便我可以相应地调整值.即我如何计算出isTablet的价值?
if(isTablet) { orientation += -90; if(orientation < 0) //Check if we have gone too far back,keep the result between 0-360 { orientation += 360; } }
解决方法
看看this reference.
您可以使用android.os.Build.DEVICE,android.os.Build.MODEL和android.os.Build.PRODUCT来获取设备的身份,并且根据这些知识,您可以使用this参考来查找其值并确定什么是设备类型.
但是,使用此方法,每次发布新平板电脑时都必须更新软件. (我已经使用this问题作为答案的这一部分的参考).
替代是我在here找到的,引用答案:
public boolean isTablet(Context context) { boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4); boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE); return (xlarge || large); }
LARGE and XLARGE Screen Sizes are determined by the manufacturer based
on the distance from the eye they are to be used at (thus the idea of
a tablet).
希望这可以帮助!
ActivitiException: Activiti database problem: Tables missing for component(s) identity
报错信息:
Caused by: org.activiti.engine.ActivitiException: Activiti database problem: Tables missing for component(s) identity
at org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion(DbSqlSession.java:886)
at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:1360)
原因是数据库中缺少 activiti 用的 ACT_ID_* 的表。 可以从 activiti 的 jar 包中解压出建表 sql。
android Drawable – getConstantState.newDrawable()vs mutate()
我正在阅读的文章是 here
现在我的问题:
android中以下两个调用之间有什么区别:
Drawable clone = drawable.getConstantState().newDrawable(); // vs Drawable clone = (Drawable) drawable.getDrawable().mutate();
对我来说,他们都克隆了一个drawable,因为他们都返回了一个没有共享状态的drawable.我错过了什么吗?
解决方法
A mutable drawable is guaranteed to not share its state with any other drawable
因此,在不影响具有相同状态的drawable的情况下更改drawable是安全的
让我们玩这个drawable – 黑色的形状
<!-- shape.xml --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@android:color/black" /> </shape>
view1.setBackgroundResource(R.drawable.shape); // set black shape as a background view1.getBackground().mutate().setTint(Color.CYAN); // change black to cyan view2.setBackgroundResource(R.drawable.shape); // set black shape background to second view
相反的方法是newDrawable().它创建了一个新的drawable但具有相同的常量状态.例如.看看BitmapDrawable.BitmapState:
@Override public Drawable newDrawable() { return new BitmapDrawable(this,null); }
对新drawable的更改不会影响当前drawable,但会更改状态:
view1.setBackgroundResource(R.drawable.shape); // set black shape as background Drawable drawable = view1.getBackground().getConstantState().newDrawable(); drawable.setTint(Color.CYAN); // view still black view1.setBackground(drawable); // Now view is cyan view2.setBackgroundResource(R.drawable.shape); // second view is cyan also
android – ChildEventListener和ValueEventListener Firebase接口有什么区别?
文档说他们都在Firebase数据库位置收听更改.
解决方法:
虽然ChildEventListener有时可以更灵活,但它们几乎完全相同:使用ChildEventListener,您可以为4个操作指定不同的行为(onChildAdded,onChildChanged,onChildMoved和onChildRemoved),而ValueEventListener仅提供onDataChanged.
ChildEventListener还在子位置提供DataSnapshots(数据的不可变副本),而ValueEventListener提供整个节点的DataSnapshot.
android – firebase的addValueEventListener()和addListenerForSingleValueEvent()之间的区别
正如标题所说,我想知道firebase的addValueEventListener()和addListenerForSingleValueEvent()之间的区别.
解决方法:
addValueEventListener()继续监听它所附加的查询或数据库引用.
但是addListenerForSingleValueEvent()会立即执行onDataChange方法,并且在执行该方法一次后,它会停止侦听它所附加的引用位置.
关于android – OrientationEventListener(Tablet vs Mobile)90度差异的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于ActivitiException: Activiti database problem: Tables missing for component(s) identity、android Drawable – getConstantState.newDrawable()vs mutate()、android – ChildEventListener和ValueEventListener Firebase接口有什么区别?、android – firebase的addValueEventListener()和addListenerForSingleValueEvent()之间的区别等相关内容,可以在本站寻找。
本文标签: