小编use*_*185的帖子

如何将图像放在Android单选按钮的右侧

我正在尝试制作4个项目的单选按钮列表.每个项目都需要正确的文本,但也需要文本右侧的图像.图像不是单选按钮本身,而是描述该选项的图像.到目前为止我没有运气,设计师似乎没有办法把事情放到位.你必须知道如何用XML编写代码.我的XML看起来像这样:

<?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="match_parent" android:weightSum="1" android:baselineAligned="true" android:orientation="horizontal">
    <RadioGroup android:layout_weight="0.50" android:layout_height="wrap_content" android:id="@+id/radioGroup1" android:layout_width="0dp">
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="true" android:text="A" android:id="@+id/radio0"></RadioButton>
        <ImageView android:layout_toRightOf="@id/radio0" android:layout_height="wrap_content" android:src="@drawable/A2" android:layout_width="wrap_content" android:id="@+id/imageView1"></ImageView>
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="B" android:id="@+id/radio1"></RadioButton>
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="C" android:id="@+id/radio2"></RadioButton>
        <RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="D" android:id="@+id/radio3"></RadioButton>
    </RadioGroup>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在这里,我试图将一个图像放在第一个单选按钮的右侧,但没有成功.如何将图像放在单选按钮的右侧?

android image radio-button

12
推荐指数
1
解决办法
2万
查看次数

Android Camera Preview YUV格式在GPU上转成RGB

我已经复制粘贴了我在 stackoverflow 上找到的一些代码,将默认的相机预览 YUV 转换为 RGB 格式,然后将其上传到 OpenGL 进行处理。效果很好,问题是大部分 CPU 都忙于将 YUV 图像转换为 RGB 格式,结果变成了瓶颈。

我想将 YUV 图像上传到 GPU,然后在片段着色器中将其转换为 RGB。我采用了相同的 Java YUV 到 RGB 函数,我发现它在 CPU 上工作,并试图让它在 GPU 上工作。

它变成了一个相当小的噩梦,因为在 Java 和 GPU 上进行计算存在一些差异。首先,预览图像在 Java 中以 byte[] 形式出现,但字节是有符号的,因此可能存在负值。

此外,片段着色器通常处理 [0..1] 浮点值而不是字节。

我确信这是可以解决的,我几乎解决了。但我花了几个小时试图找出我做错了什么,但无法让它发挥作用。

最重要的是,我要求某人编写此着色器函数并最好对其进行测试。对我来说,这将是一项乏味的猴子工作,因为我真的不明白为什么这种转换会以这样的方式工作,而我只是尝试在 GPU 上模仿相同的功能。

这与我在 Java 上使用的功能非常相似: Displaying YUV Image in Android

我在CPU上做了一些工作,比如把1.5*w h bytes的YUV格式变成aw h*YUV,如下:

static public void decodeYUV420SP(int[] rgba, byte[] yuv420sp, int width,
        int height) {
    final int frameSize = width * height;

    for (int j = …
Run Code Online (Sandbox Code Playgroud)

java rgb android gpu yuv

6
推荐指数
1
解决办法
5679
查看次数

AFNetworking 2.0 POST问题,Cocoa错误3840(JSON文本没有以数组开头......)

我试图在我的本地服务器上调用api.php(使用MAMP).正在调用服务器端api.php,但php代码中的_POST内容包含以下错误:

Error Domain = NSCocoaErrorDomain Code = 3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo = 0x15d7bdd0 {NSDebugDescription = JSON text did not start with array or object and option to allow fragments not set.}
Run Code Online (Sandbox Code Playgroud)

我的应用程序试图将JSON POST请求发送到api.php是一个使用AFNetworking 2的iOS应用程序

这是我的请求代码:

- (void)postUpdateRequest
{
    if (!dataModel)
        dataModel = [[DataModel alloc] init];

    NSDictionary *params = @{@"foo": @"bar2"};

    NSLog(@"%@",params);

/*    NSDictionary *params = @{@"cmd":@"update",
                             @"user_id":[dataModel userId], …
Run Code Online (Sandbox Code Playgroud)

php json objective-c ios afnetworking-2

6
推荐指数
1
解决办法
1万
查看次数

CGImageRef cg = [[UIImage imageNamed:Path] CGImage]; 需要CGImageRelease(cg)'?

我试图从iOS中的图像资源中读取ARGB像素.为此,我需要一个CGImageRef我可以使用它来获得它CGDataProvider.我的问题是,如果我创建一个CGImageRef使用:

CGImageRef cg = [[UIImage imageNamed: Path] CGImage];
Run Code Online (Sandbox Code Playgroud)

我最终还需要打电话CGImageRelease(cg)吗?如果我不打电话CGImageRelease,我会有内存泄漏吗?

我遇到的另一个问题是第二次读同一个文件会返回一个空图像,我怀疑这可能是因为我CGImageRelease第一次没有打电话.

objective-c core-foundation cgimage ios

2
推荐指数
1
解决办法
1091
查看次数