简体   繁体   中英

android: service layout not showing any TextView in some devices

I am using Service to show a overlay View even if my app closed. but this layout not showing any TextView . in android studio Preview, my layout is like this:

![在此处输入图片描述

but after running in some devices:

在此处输入图片说明

all of TextView s not showing in some device. 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.

I use android:textColor="" attribute for TextViews and now worked properly. Idon't know why default text color not wor in som devices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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