小编Jov*_*van的帖子

Android getResource()未定义错误

我想在MyPositionOverlay中绘制方法的位图扩展Overlay类但是我得到了这个错误:方法getResource()未定义类型MyPositionOverlay

哪里我错了?

这是代码表单绘制方法:

  Bitmap bmp = BitmapFactory.decodeResource(getResource(), R.drawable.icon); 
     canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);
Run Code Online (Sandbox Code Playgroud)

谢谢

android

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

android减少两个垂直TextView之间的空间

我的应用程序中有两个垂直TextView元素.TextViews之间有很多空间,pading和layoutMargin都是0

有没有办法减少这个空间?

在两个文本视图之间的图像空间 - 填充和边距为0

编辑这是我的代码:

.
.

<LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="right"
            android:paddingRight="10dp"
            android:layout_weight="1">
                <TextView 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/text_size_extra_small"
                    android:textColor="@color/home_tab_text_normal"
                    android:text="Test1"/>
                <TextView 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/orange_text_color"
                    android:textSize="@dimen/text_size_large"
                    android:textStyle="bold"
                    android:text="Text2"/>


        </LinearLayout>         

.
.
Run Code Online (Sandbox Code Playgroud)

Thnaks

android android-layout

8
推荐指数
2
解决办法
8962
查看次数

android:通过代码在PopupWindow上设置margin

我想在popupwindow上设置左右边距.我尝试设置布局参数layout,然后设置保证金,但不起作用.

谁能给我代码在popupwindow上设置保证金

这是代码

LayoutInflater inflater = (LayoutInflater) QuestionsActiviy.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.popup, (ViewGroup) findViewById(R.id.popup_element));


        ratePw = new PopupWindow(layout);
        ratePw.setWidth(WindowManager.LayoutParams.FILL_PARENT);
        ratePw.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        ratePw.setFocusable(true);

        ratePw.showAtLocation(layout, Gravity.CENTER, 0, 0);
Run Code Online (Sandbox Code Playgroud)

谢谢.

android

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

将Libgdx项目从Eclipse迁移到Android Studio时出错

我正在尝试将我现有的游戏(用libgdx编写)从Eclipse迁移到Android Studio.迁移我的桌面项目后正常工作,但我的Android项目有问题.在android我正在使用Admob广告.

我收到以下错误消息:

在此输入图像描述

如您所见,Android Support Repository已安装 SDK Manager

我的项目结构:

在此输入图像描述

在Project Gradle文件中,我有这个:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'org.robovm:robovm-gradle-plugin:1.9.0'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = 'My Game'
        gdxVersion = '1.7.1'
        roboVMVersion = '1.9.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.6.0'
    }

    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url 'https://oss.sonatype.org/content/repositories/releases/' }
    }
}

project(":desktop") {
    apply plugin: …
Run Code Online (Sandbox Code Playgroud)

android gradle libgdx android-studio

7
推荐指数
1
解决办法
648
查看次数

统一确保已启用读/写

我是Unity新手。

有人可以告诉我这个错误是什么意思

Ensure Read/Write is enabled on the Particle System's Texture 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

粒子系统需要在开始时播放,但有时不需要工作(播放效果)。谢谢

unity-game-engine particle-system

6
推荐指数
2
解决办法
5900
查看次数

Android,删除自定义按钮边框

我将这个选择器代码用于我的自定义按钮(simple.xml)

  <?xml version="1.0" encoding="utf-8"?>

  <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/focused" />
      <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" />
      <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" />
      <item android:drawable="@drawable/defaultbutton" />
  </selector>
Run Code Online (Sandbox Code Playgroud)

但在我的ImageButton上,我不知道如何删除边框.我想只显示我的图像,不显示按钮周围的边框.

谢谢 替代文字

android background imagebutton

5
推荐指数
1
解决办法
7982
查看次数

Android:LinearLayout中的中心ImageButton

如何将ImageButton置于此LinearLayout中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main"
>
Run Code Online (Sandbox Code Playgroud)

的ImageButton

              <ImageButton android:id="@+id/btnBut"
                      android:background="@drawable/button"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

我不想使用固定尺寸.

谢谢

android

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

将Android Studio更新为1.5后出现Gradle错误

今天我已将Android Studio更新为v1.5.我有libgdx项目,在此更新之前运行良好.现在我收到此错误消息.

    Error:Unable to load class 'org.gradle.mvn3.org.sonatype.aether.resolution.ArtifactResolutionException'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the …
Run Code Online (Sandbox Code Playgroud)

android gradle libgdx android-studio

5
推荐指数
1
解决办法
4038
查看次数

Android删除PopupWindow背景

我使用PopupWindow类创建自定义弹出窗口.

但是当我在main上添加layout_margin(在我的示例中为15dp)时,会有透明的灰色背景.

如何删除透明背景?

请看图片

在此输入图像描述

编辑这里是我的代码

    window = new PopupWindow(customTool.getContext());
    window.setWidth(WindowManager.LayoutParams.FILL_PARENT);
    window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    window.setTouchable(true);
    window.setFocusable(true);
    window.setOutsideTouchable(true);
    window.setAnimationStyle(R.style.Animations_PopDownMenu_Left);
window.setContentView(customTool);
    window.showAtLocation(customTool, Gravity.NO_GRAVITY, 0, 100);
Run Code Online (Sandbox Code Playgroud)

android

4
推荐指数
1
解决办法
7602
查看次数

libGDX使touchDown循环直到touchUp

我正在用libGDX制作游戏.

我想实现游戏控制,但我的touchDown方法有问题.touchDown方法只运行一次.我想在touchDown中循环,直到调用touchUp.有人能帮我吗 ?

class  onPlayerGoLeftListener extends InputListener {

    public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        //start runnable   (move player)     

        return true;
    }

    public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        //stop runnable
    }

}
Run Code Online (Sandbox Code Playgroud)

谢谢

ps我不喜欢使用主更新方法来做到这一点

libgdx

3
推荐指数
1
解决办法
946
查看次数