小编Dou*_*P90的帖子

强制平板电脑使用xhdpi资源

我正在处理一个应用程序,我已经提供了从ldpi到xhdpi的所有资源,但是有些平板电脑使用hdpi(或者在我正在测试的nexus 7的情况下使用tvdpi)所以当我在平板电脑上打开应用程序时一切都很小,我想强迫他们使用xhdpi资源我该怎么做?

我不想仅为平板电脑创建单独的文件,或者应用程序的大小会增加,xhdpi资源可以正常工作

在此输入图像描述

在手机上一切正常显示,平板电脑是问题,因为它们为大屏幕采用小分辨率资产,所以实际尺寸以英寸(4厘米,用尺子测量)是正确的,但它们实际上看起来很小,使得整体设计不正确

xml android

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

以编程方式绘制气泡

我希望在我的应用程序中有一个具有百分比值的气泡,我不能使用9个补丁,因为我希望它可以自定义并且它的背景颜色应该是可变的.看起来应该是这样的 在此输入图像描述

我该怎么做?这个泡泡会在其内部膨胀视图,如此百分比或一些较大的布局.也取决于布局(手机或平板电脑),它可能有一侧比另一侧大(箭头不在中心)所以这是我更喜欢以编程方式进行的另一个原因

android android-canvas

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

Android Studio SDK问题

我想尝试新的Android Studio,但是当我启动它时,我得到了这个错误

    null
java.lang.NullPointerException
    at com.android.ide.common.resources.ResourceResolver.getStyle(ResourceResolver.java:574)
    at com.android.ide.common.resources.ResourceResolver.computeStyleInheritance(ResourceResolver.java:503)
    at com.android.ide.common.resources.ResourceResolver.computeStyleMaps(ResourceResolver.java:462)
    at com.android.ide.common.resources.ResourceResolver.create(ResourceResolver.java:75)
    at com.android.tools.idea.configurations.Configuration.getResourceResolver(Configuration.java:1059)
    at org.jetbrains.android.AndroidColorAnnotator.annotateResourceReference(AndroidColorAnnotator.java:193)
    at org.jetbrains.android.AndroidColorAnnotator.annotate(AndroidColorAnnotator.java:101)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:160)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:103)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$11.run(GeneralHighlightingPass.java:650)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:763)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.access$3500(GeneralHighlightingPass.java:83)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$13.run(GeneralHighlightingPass.java:769)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:87)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:766)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.access$3500(GeneralHighlightingPass.java:83)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$13.run(GeneralHighlightingPass.java:769)
    at com.intellij.codeInsight.daemon.impl.RefCountHolder.analyze(RefCountHolder.java:295)
    at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.analyze(HighlightVisitorImpl.java:139)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:766)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:723)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:214)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:58)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:62)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:357)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1196)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:348)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:345)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:321)
    at com.intellij.concurrency.JobLauncherImpl$3.call(JobLauncherImpl.java:145)
    at com.intellij.concurrency.JobLauncherImpl$3.call(JobLauncherImpl.java:142)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at com.intellij.concurrency.PrioritizedFutureTask.access$101(PrioritizedFutureTask.java:31)
    at com.intellij.concurrency.PrioritizedFutureTask$1.run(PrioritizedFutureTask.java:70)
    at com.intellij.concurrency.PrioritizedFutureTask.run(PrioritizedFutureTask.java:113)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) …
Run Code Online (Sandbox Code Playgroud)

intellij-idea android-studio

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

循环进度条

我正在开发一个需要"圆形进度条"的应用程序(它不需要进行颜色更改或者在中间是空的,对我来说应该是一件简单的事情,但是如果你愿意的话告诉我如何改变颜色,我也很乐意学习:))

在此输入图像描述

我想用它来显示我的应用中的电池百分比

android

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

MediaRecorder仅以15 FPS录制

我正在制作相机应用程序,我有一个问题,我无法设置视频的帧速率,我的代码看起来像这样我将帧速率设置为30,但它忽略它,它记录在15,我知道在某些设备上它没有设置实际的帧速率而是建议的帧速率,并且手机根据光线决定,但是我在外面录制光线并且它仍然以低fps录制,可能我做错了

MediaRecorder recorder;
Camera camera;
SurfaceView preview;
SurfaceHolder holder;
boolean isRecording = false;
String TAG = "Evolution Camera";
int frameRate = 30;


public static final int MEDIA_TYPE_IMAGE = 1;
public static final int MEDIA_TYPE_VIDEO = 2;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentView(R.layout.camera_view);

    preview = (SurfaceView) findViewById(R.id.camera_preview);


 // Add a listener to the Capture button
    ImageButton captureButton = (ImageButton) findViewById(R.id.btn_capture);
    captureButton.setOnClickListener(
        new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                record();
            }
        }
    );
} …
Run Code Online (Sandbox Code Playgroud)

android

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

电池改变了一些手机上的广播接收器崩溃应用程序

每当手机插上电源时,我都会激活我的应用程序.这是我的表现

<receiver android:name=".PowerConnectionReceiver">
      <intent-filter>
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
        <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
      </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

这是我的广播接收器

  @Override
    public void onReceive(Context context, Intent intent) {
        Log.w("TAG", "Just received connection broadcast");


        IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        Intent batteryStatus = context.registerReceiver(null, ifilter); //this line is causing the crash


        int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
Run Code Online (Sandbox Code Playgroud)

现在,导致我的朋友电话崩溃的线路(我的一切工作正常)就是这一行

Intent batteryStatus = context.registerReceiver(null, ifilter);
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我是什么原因以及如何解决它?我的手机是最新的Android JB的Galaxy nexus,他的手机是LG optimus与姜饼

这是logcat

    02-27 01:25:19.399: D/AndroidRuntime(5326): Shutting down VM
02-27 01:25:19.399: W/dalvikvm(5326): threadid=1: thread exiting with uncaught exception (group=0x40018560)
02-27 01:25:19.419: E/AndroidRuntime(5326): FATAL EXCEPTION: main
02-27 01:25:19.419: …
Run Code Online (Sandbox Code Playgroud)

android

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

主页按钮带回我的应用程序

我正在制作一个汽车启动器应用程序,其中包含其他应用程序的快捷方式,当我在另一个应用程序时,我想按下主页按钮并返回到我的启动器所以基本上我需要覆盖我的应用程序之外的主页按钮,覆盖必须只在我的应用程序在后台打开时工作,所以当我关闭我的应用程序时,主页按钮将照常工作,将您带到默认启动器

我可以实现这样的东西,或者我要求太多了吗?

java android

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

在共享偏好中保存意图

我有一个应用程序,我可以启动我的手机上安装的其他应用程序,长按我得到应用程序选择器,结果我收到一个意图数据,我如何保存它,以便用户关闭时回到我的应用程序有相同的快捷方式设置?

我保存这样的其他东西

SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
  SharedPreferences.Editor editor = settings.edit();
  editor.putInt("Counter1", counter);
  editor.putBoolean("FirstRun", firstRun);
  editor.putString("Label2", label2S);

  editor.commit();
Run Code Online (Sandbox Code Playgroud)

但我无法对意图做同样的事情

java android

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