tiper / MaterialSpinner

Implementation of a Material Spinner for Android with TextInputLayout functionalities
Apache License 2.0
130 stars 30 forks source link

How do i implement style in java code programatically. #27

Closed tiper closed 4 years ago

tiper commented 4 years ago

How do i implement style in java code programatically.I tried in two ways such as :

1st : com.tiper.MaterialSpinner materialSpinner = new com.tiper.MaterialSpinner(this,null,R.style.Widget_MaterialComponents_TextInputLayout_OutlinedBox); ///// Not working

2nd : com.tiper.MaterialSpinner spinner = new com.tiper.MaterialSpinner(new androidx.appcompat.view.ContextThemeWrapper(this, R.style.Widget_MaterialComponents_TextInputLayout_OutlinedBox));

Originally posted by @rajvimal in https://github.com/tiper/MaterialSpinner/issues/6#issuecomment-613498175

tiper commented 4 years ago

Hi @rajvimal, you question is not related with this issue

Have you tried with LayoutInflater?

MaterialSpinner spinner = LayoutInflater.from(context).inflate(R.layout.spinner_outlined_box, null);

The spinner_outlined_box can be: <?xml version="1.0" encoding="utf-8"?> <com.tiper.MaterialSpinner xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" />