0

Мне нужно установить AppTheme_Transparent для моего кастомного layout toast. Но с приведенным ниже кодом этого не происходит. Может быть, я делаю это с неправильным контекстом ?!

LayoutInflater inflater = getLayoutInflater();
LinearLayout linearLayout =  findViewById(R.id.toast_layout);

Context context = getApplicationContext();
context.setTheme(R.style.AppTheme_Transparent);
View layout = inflater.cloneInContext(context).inflate(R.layout.info_layout,
        linearLayout);

Toast toast = new Toast(context);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(layout);
toast.show();

Подскажите, пожалуйста, как мне решить данную проблему?

1 ответ 1

0
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.info_layout, (ViewGroup) findViewById(R.id.toast_layout));

Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();

android:background="@android:color/transparent" 
2
  • Это решает проблему, но не через тему. В принципе и так сойдет, спасибо. 3 окт 2018 в 17:02
  • @AndrewEfremov, зато оперативно :)
    – iFr0z
    3 окт 2018 в 17:22

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.