Created
March 3, 2015 12:12
-
-
Save alexfu/d2510aa3a40ef805f216 to your computer and use it in GitHub Desktop.
Change View styles on the fly with ContextThemeWrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyFragment { | |
private Context context; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
// Where the magic happens | |
context = new ContextThemeWrapper(getActivity(), R.style.Theme_Main_Inverse); | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, | |
@Nullable Bundle savedInstanceState) { | |
inflater = LayoutInflater.from(context); | |
View view = inflater.inflate(R.layout.fragment_myprofile, container, false); | |
ButterKnife.inject(this, view); | |
bindViews(); | |
return view; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<style name="Theme.Main" parent="Theme.AppCompat.Light.NoActionBar"/> | |
<style name="Theme.Main.Inverse" parent="Theme.AppCompat.NoActionBar"/> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment