我正试图RelativeLayout在API 22上实现涟漪效应,但它没有显示出来.然而,同样的波纹起作用Button.
我的波纹drawable的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#d1c4e9">
<item android:id="@android:id/mask"
android:drawable="@android:color/white" />
<item android:drawable="@drawable/rect"/>
</ripple>
Run Code Online (Sandbox Code Playgroud)
相对布局代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/ripple">
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在此之后,波动被设定为在背景Button和RelativeLayout.按钮上的波纹效果很好,但根本没有出现RelativeLayout.
谁能告诉我我做错了什么?
我正在尝试开发一个Android应用程序,将图像从一个设备传输到另一个设备.然后,接收到的图像将显示在我的应用程序内的ImageView上.为了完成我的任务,我想发送一个位图的字节数组.我能够在imageview上获得第一张图片.但是,只要我点击按钮发送另一个图像,应用程序就无法发送位图.它向我显示了一个异常"java.io.IOException:Service fiscovery failed".要成功发送任何图像,我需要在接收/远程设备上重新启动我的应用程序.任何人都可以建议解决mu问题.logcat也包含在下面.
建立连接的代码:
private class StartConnectionThread extends Thread{
private final BluetoothSocket bluetoothSocket;
private final BluetoothDevice bluetoothDevice;
public StartConnectionThread(BluetoothDevice device){
BluetoothSocket tempBluetoothSocket=null;
bluetoothDevice=device;
try
{
System.out.println(uuid);
tempBluetoothSocket=device.createRfcommSocketToServiceRecord(uuid);
}
catch(IOException ioException)
{
}
bluetoothSocket=tempBluetoothSocket;
}
@Override
public void run() {
// TODO Auto-generated method stub
bluetoothAdapter.cancelDiscovery();
try
{
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bluetoothSocket.connect();
}
catch(IOException ioException)
{
System.out.println("bluetoothSocketInThread failed");
try
{
bluetoothSocket.close();
}
catch(IOException cancelIOException)
{ …Run Code Online (Sandbox Code Playgroud)