我们可以在另一个大视图上放置一个小视图吗?例如,我有一个在后台播放文件的VideoView.在这个,在中间/角落的某个地方,我想放置另一个ImageView.
但是在线性/相对布局中,视图可以一个接一个地放置,也可以相对于彼此放置,建议不要使用AbsoluteLayout.那我该怎么办?
我在想什么?
我试图用可绘画/油漆在脸上拍照,但是,我无法在同一张照片上同时拍摄.
我试过了什么?
我尝试过使用,CameraSource.takePicture但我只是脸上没有任何可绘画/油漆.
mCameraSource.takePicture(shutterCallback, new CameraSource.PictureCallback() {
@Override
public void onPictureTaken(byte[] bytes) {
try {
String mainpath = getExternalStorageDirectory() + separator + "TestXyz" + separator + "images" + separator;
File basePath = new File(mainpath);
if (!basePath.exists())
Log.d("CAPTURE_BASE_PATH", basePath.mkdirs() ? "Success": "Failed");
String path = mainpath + "photo_" + getPhotoTime() + ".jpg";
File captureFile = new File(path);
captureFile.createNewFile();
if (!captureFile.exists())
Log.d("CAPTURE_FILE_PATH", captureFile.createNewFile() ? "Success": "Failed");
FileOutputStream stream = new FileOutputStream(captureFile);
stream.write(bytes);
stream.flush();
stream.close();
} catch (IOException e) { …Run Code Online (Sandbox Code Playgroud) 布局时我遇到了一个非常奇怪的问题.它看起来像在eclipse XML编辑器和我的三星galaxy中设计但它在我的旧手机xperia x10 mini中搞砸了.我只能假设这也会在其他设备中出现.
如果有人可以帮忙解决这个问题,我将不胜感激.
以下是两个屏幕截图和XML代码.
它在eclipse布局编辑器和我的三星galaxy S4 mini中看起来如何
它在Sony xperia x10 mini中的外观如何
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_marginTop="7dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View android:layout_marginTop="19dp" android:layout_marginLeft="19dp" android:layout_height="249dp" android:layout_width="2dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="19dp" android:layout_marginLeft="189dp" android:layout_height="249dp" android:layout_width="2dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="18dp" android:layout_marginLeft="20dp" android:layout_height="2dp" android:layout_width="170dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="267dp" android:layout_marginLeft="19dp" android:layout_height="2dp" android:layout_width="171dp" android:background="#B2CFEF"/>
<ImageView style="@style/ta_img" android:id="@+id/ta_lu" android:layout_marginTop="52dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_lc" android:layout_marginTop="124dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_ld" android:layout_marginTop="197dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_ru" android:layout_marginLeft="170dp" android:layout_marginTop="52dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_rc" android:layout_marginLeft="170dp" android:layout_marginTop="124dp" />
<ImageView …Run Code Online (Sandbox Code Playgroud) android android-layout android-linearlayout android-framelayout android-constraintlayout
我目前正在尝试了解Android即时应用程序.由于我没有任何支持它们的真实设备,我使用的是模拟器(来自Android Studio 3.0 Canary 9).我可以成功运行的"玩具"即时应用程序(像这样在我的模拟的Nexus 5X)(与Play商店),所以我相信我的开发环境配置是否正确.
但是,我很想知道第三方应用程序的发现过程,并了解用户体验是什么样的.由于缺乏合适的设备,我使用模拟的Chrome浏览器搜索启用了即时应用的网站(如Stack Exchange).但这些搜索只给我通常的网站(不是即时应用程序).
我非常感兴趣地阅读这篇文章,因为它似乎表明这应该有效.但是,这些答案似乎对我没有帮助.
API 24和API 26模拟设备(两者都包括Play商店)目前处于不同的状态,可能是因为我一直在尝试各种技巧来使其工作.(TLDR:没有什么对我有用.)
在API 24模拟设备上,如果我键入,adb shell pm list packages grep "com.google.android.instantapps.supervisor"那么它输出package:com.google.android.instantapps.supervisor为一个答案建议(但它仍然不起作用).
已Google Play services for Instant Apps (version 1.9-sdk-155682639)安装API 24设备.
API 24设备在屏幕顶部显示"闪电"通知,说"开发模式有效": URLs will be routed to Dev Manager in order to launch Instant Apps locally. Uninstall Dev Manager to disable Development Mode.
在API 24设备上,设置 - > Google - >即时应用,即时应用设置为true
在API 26模拟设备上,如果我输入adb …
android android-emulator android-instant-apps android-studio-3.0
我一直在尝试新的Android Nearby Connections v2.0 API.我的大多数设备现在可以在大多数时间互相交谈,但在尝试连接时我也会收到很多错误代码.检查status.getStatusCode()我的程序,我可以看到以下返回代码:
我很难理解这些.第一个错误代码似乎是不言自明的,只是在我没有在所谓的连接的任何一侧用"SUCCESS"返回代码命中onConnectionResult回调的情况下我看到它.我当前的代码中充满了跟踪语句,如果已经达到这些回调,我会看到日志记录条目.因此,设备可能在较低级别连接,但如果是这样,则更高级别的代码并不总能听到它.
我猜测STATUS_BLUETOOTH_ERROR表示记录它的一侧有蓝牙错误,而STATUS_ENDPOINT_IO_ERROR表示另一端有错误(可能涉及蓝牙)?是否有可能获得更多细节?我偶尔看到的STATUS_ERROR(13)状态听起来像是程序员用于那些"WTF,我们永远不会到达这里"的错误代码,但是如果没有访问源代码,我只能猜测.
请注意,我在其他时间使用相同代码精确地相互通信的设备之间会看到这些错误.有时,如果代码重试的次数足够多,它最终会获得稳定的连接.有时它会连接并立即从另一端断开连接.有时我只是得到了无休止的重复错误消息(STATUS_BLUETOOTH_ERROR和/或STATUS_ENDPOINT_IO_ERROR).
我正在使用附加连接与连接策略P2P_CLUSTER.当双方同时做广告和发现时,这些问题似乎最常发生.但是,我写了两个较小的程序,专门从事广告或发现,他们有时也会得到这些错误(但不常见).
在跟踪消息中,我还注意到来自Nearby Connections的大量警告消息如下所示:
09-04 22:54:40.070 3866-3924/? W/NearbyConnections: Cannot deserialize BluetoothDeviceName: expecting min 16 raw bytes, got 6
Run Code Online (Sandbox Code Playgroud)
我猜这是因为Nearby Connections使用自己的短令牌(比如ZGbx)而不是设备的蓝牙名称?不过,我对此并不确定.无论如何,如果这些是Nearby Connections自己的特殊令牌,那为什么会发出有关它的警告信息呢?
我正在尝试将新的Android Nearby Connections v2.0 API 与P2P_CLUSTER连接策略一起使用。以下问题(两个设备都请求连接,但未成功连接)似乎出现在运行 Android KN 的各种设备上。有时代码会获得成功的持久连接……有时不会。
在这种场景下,双方都在广播和发现,双方互相发现,双方都发送连接请求(但没有发起连接)。使用特定的测试用例很难使这种情况可靠地发生,但它确实发生了。
使用 Android Monitor,我从一侧捕获了有关此场景的详细信息,并在下面列出了事件序列。在这个特定的会话中,我监控的设备是非常便宜的 KitKat 手机,远程端点是 Samsung Lollipop 平板电脑(以防万一)。
requestConnection紧接着,Android Monitor 显示此错误:
09-28 11:49:38.706 17321-17823/? E/NearbyConnections: In startClient(), UKEY2 failed with endpoint AqXW
java.io.IOException: bt socket closed, read return: -1
at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:647)
at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:96)
at java.io.InputStream.read(InputStream.java:162)
at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
at java.io.BufferedInputStream.read(BufferedInputStream.java:295)
at libcore.io.Streams.readFully(Streams.java:81)
at java.io.DataInputStream.readInt(DataInputStream.java:103)
at xkj.c(:com.google.android.gms@11509230:1)
at xkg.run(:com.google.android.gms@11509230:8)
at mng.run(:com.google.android.gms@11509230:25)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at mso.run(:com.google.android.gms@11509230)
at java.lang.Thread.run(Thread.java:818)
Run Code Online (Sandbox Code Playgroud)紧接着,它使用STATUS_ENDPOINT_IO_ERROR(8012)命中 requestConnection 的 ResultCallback 。
我有一个CoordinatorLayout包含a CollapsingToolbarLayout和a的RecyclerView.一切都看起来像它应该的样子,除了当我尝试以编程方式滚动到最后一个项目时,它不会一直到底部.相反,它这样做:
我不认为这是一个剪辑问题,因为如果我向下滚动,底部项目完全在那里:
这是主要布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="150dp"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="16dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStart="72dp"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/recyclerview_bottom_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是上面屏幕提示的代码:
class TestActivity : AppCompatActivity() {
private val itemNames = listOf("top item", "next item", "yada", "yada yada", "yada yada yada", "second last item", "last item")
private val selectedPosition = itemNames.size - 1
override …Run Code Online (Sandbox Code Playgroud) android android-recyclerview android-collapsingtoolbarlayout
android ×8
bluetooth ×2
android-collapsingtoolbarlayout ×1
overlapping ×1
views ×1
vision-api ×1