简体   繁体   English

android:服务布局在某些设备中不显示任何TextView

[英]android: service layout not showing any TextView in some devices

I am using Service to show a overlay View even if my app closed. 即使我的应用已关闭,我仍在使用Service显示叠加View but this layout not showing any TextView . 但是此布局未显示任何TextView in android studio Preview, my layout is like this: 在android studio预览中,我的布局是这样的:

![在此处输入图片描述

but after running in some devices: 但在某些设备上运行后:

在此处输入图片说明

all of TextView s not showing in some device. 所有TextView均未在某些设备上显示。 but other views showing. 但显示其他视图。

portion of my code is here: 我的代码的一部分在这里:

public class FloatingWindowServices extends Service {
    ...

    @Override
    public IBinder onBind(Intent intent) {
      return null;
    }

    @Override
    public void onCreate() {
      super.onCreate();
      context = this;
      handler = new Handler();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
      LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      mView = layoutInflater.inflate(R.layout.floating_service_layout, null);

      findViews();
      initialize();
      initButtonClicks();
      moveView();

      return super.onStartCommand(intent, flags, startId);
    }

    ...
  }

I change compileSdkVersion and app style as someone mentioned in another answers but I don't see any change. 我更改了compileSdkVersion和应用程序style就像其他答案中提到的那样,但是我看不到任何变化。

I use android:textColor="" attribute for TextViews and now worked properly. 我将android:textColor=""属性用于TextViews ,现在可以正常工作。 Idon't know why default text color not wor in som devices. 我不知道为什么Som设备中的默认文本颜色不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM