假设我在Kotlin中有一个字符串列表: stringList: MutableList<String>
然后通过这样做很容易按不区分大小写的顺序对这样的列表进行排序:
stringList.sortWith(String.CASE_INSENSITIVE_ORDER)
Run Code Online (Sandbox Code Playgroud)
但是,如何按不区分大小写的顺序对对象列表进行排序?例如:places: MutableList<Place>
哪个Place是带有2个字段的简单类 - name: String而且id: Int,我想按name字段对这些地方进行排序.
我试图做这样的事情:places.sortedWith(compareBy { it.name })但是这个解决方案并没有考虑到字母的情况.
我有一个Android应用程序,用户用前置摄像头拍摄自己的照片,然后将照片上传到我的服务器.我注意到许多照片来到我的服务器太暗(有时几乎不可能看到用户脸上的清晰).
我想在应用程序端过滤掉这些照片并显示通知(例如"照片太暗.再拍一张照片")给用户.我怎样才能在Android中完成这样的任务?
编辑:
我已经找到了如何计算单个像素的亮度(感谢这个答案:https://stackoverflow.com/a/16313099/2999943):
private boolean isPixelColorBright(int color) {
if (android.R.color.transparent == color)
return true;
boolean rtnValue = false;
int[] rgb = {Color.red(color), Color.green(color), Color.blue(color)};
int brightness = (int) Math.sqrt(rgb[0] * rgb[0] * .299 + rgb[1]
* rgb[1] * .587 + rgb[2] * rgb[2] * .114);
if (brightness >= 200) { // light color
rtnValue = true;
}
return rtnValue;
}
Run Code Online (Sandbox Code Playgroud)
但我仍然不清楚如何确定整个图像亮度"状态".有什么建议?
我的应用包含Google maps v2 API片段视图.点击按钮我想要从左到右改变它的宽度:谷歌地图拍摄半屏 - >谷歌地图全屏显示.
它有效,但在宽度过渡期间,我在屏幕右侧看到奇怪的黑色区域.我已经读过这是谷歌的bug,并且他们已经发布了针对此的修复程序,但它仅适用于Android 4.1版本.我使用的是Android 4.0
此外,我检查了另一个人提到的一些变通方法,但他们都专注于滚动等任务.没有人提到谷歌地图视图宽度变化.
有人可以帮帮我吗?
我的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="510dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" />
<ImageView
android:id="@+id/mapExpandButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="25dp"
android:layout_marginRight="510dp"
android:background="@drawable/map_expand" />
<ImageView
android:id="@+id/mapCloseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="25dp"
android:layout_marginLeft="15dp"
android:background="@drawable/map_close" />
Run Code Online (Sandbox Code Playgroud)
谷歌地图初始化:
mapFragment = (SupportMapFragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
map = mapFragment.getMap ();
map.getUiSettings().setRotateGesturesEnabled(false); // disable rotation
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(54.6873439, 25.2770559) , 16.0f)); // set initial position
map.getUiSettings().setZoomControlsEnabled(false);
Run Code Online (Sandbox Code Playgroud)
在"展开"按钮单击,我正在扩展谷歌地图,如下所示:
ResizeWidthAnimation anim = new ResizeWidthAnimation(mapFragment.getView (), width); …Run Code Online (Sandbox Code Playgroud) 我想在从 Activity A 切换到 Activity B 时执行共享元素过渡。问题是,当共享 imageView缩放类型不同时,过渡动画无法顺利工作。我注意到在过渡的一开始就有一个“反弹”(我猜是在非动画 imageView 的scaleType 变化上)。当我从活动 B 返回到活动 A 时,我注意到同样的“反弹”。
细节:
Activity A 包含具有scaleType: centerCrop的 imageView 。Actvity B 包含具有scaleType: fitXY的 imageView 。
android:transitionName="sharedView"当然,两个 ImageView 都有。
我在 xml 中设置的转换如下所示:
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeBounds/>
<changeImageTransform/>
</transitionSet>
Run Code Online (Sandbox Code Playgroud)
关于此配置的文档中写道:
与 ChangeBounds 结合使用,ChangeImageTransform 允许 ImageView 更改大小、形状或ImageView.ScaleType以平滑地对内容进行动画处理。
那么为什么我的过渡过程并不顺利呢?changeBounds或者,如果withchangeImageTransform似乎不起作用,如何在共享元素转换期间对 scaleType 更改进行动画处理?
值得一提的是,如果我使共享视图的比例类型相等(例如 centerCrop 和 centerCrop) - 那么过渡工作顺利并且一切正常。
我在Google Play商店发布了一款应用.这个应用程序是专为手机设计的,我已经通过编辑清单文件中的compatible-screens元素使其无法用于平板电脑.
问题是一些大屏幕尺寸(超过5英寸)的手机也无法在Google Play商店"看到"我的应用.例如,我在Play商店中找不到我的应用程序来自三星galaxy note 4(5.7英寸,1440 x 2560像素,~515 ppi).
我应该如何设置兼容屏幕元素,以便准确分离手机和平板电脑?
<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
<screen android:screenSize="normal" android:screenDensity="480" />
<screen android:screenSize="normal" android:screenDensity="560" />
</compatible-screens>
Run Code Online (Sandbox Code Playgroud)
当我第一次发布我的应用程序时,我遇到了与nexus 6相同的问题.但我通过添加以下行来修复它:
<screen android:screenSize="normal" android:screenDensity="480" />
<screen android:screenSize="normal" android:screenDensity="560" />
Run Code Online (Sandbox Code Playgroud)
之后,我的应用程序可用于nexus 6,仍然无法用于平板电脑.我怎么能让三星Galaxy note 4也能看到它?
情况:
题:
如何完成第5步?基本上我需要知道如何以编程方式从后台恢复应用程序.
我试图启动意图"重新启动"我的应用程序活动,但它没有奏效:
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taxti"
android:versionCode="43"
android:versionName="1.5.3" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="21" />
<permission
android:name="com.example.taxti.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.taxti.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.taxti.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.taxti.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission …Run Code Online (Sandbox Code Playgroud) android ×5
java ×5
eclipse ×3
animation ×1
google-maps ×1
google-play ×1
image ×1
kotlin ×1
xml ×1