2013年12月4日星期三

android can set the style in the program code it? ( not in xml inside setting )

style.xml defined style , how to dynamically change in the program , if you can, please tell me the way
not , then please tell me if the app peels are probably how words work? I want to replace the background ( like the picture ) font size, color and so on ...
------ Solution ------------- -------------------------------
of course myself , when it can be set up in onCreate , setStyle () < br> ------ Solution ----------------------------------------- ---
whether to change the background color, font or something
first to get traded component,
such as fonts , assuming he is TextView:
1, get this TextView component: TextView tv = (TextView) findViewById (R.id.tv);
2, then tv.setTextSize (float) on the line this API , the API -specific information in the official website you can search
------ Solution ---------- ----------------------------------
is , oh , get that it will be able to carry out the component id modify ah
------ Solution -------------------------------------- ------
peels , equivalent app 's theme, and a variety of fine control , it is necessary to view the document , like textSize such , have a ready property. theme trimmer is the overall background color , borders, whether the title bar and other effects.

------ Solution ------------------------------------ --------
I said decisively not, before heading for a dynamic, transparent bar style , out of the bruised and battered , and finally changed the design to get it ......
style defined in XML which later can only get , can not be set online to find a lot of information but also did not materialize.

Of course, if there is then achieved great God , seeking implementation ......
------ Solution ---------------------- ----------------------

LinearLayout buttons = (LinearLayout)findViewById(R.id.buttonContainer);

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

inflater.inflate(R.layout.mybutton, buttons);


mybutton.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/mainButton"
        style="@style/standardButton"
/>

------ eference ------------ ---------------------------
specific point, that method ? For example, I want to set EditText or TextView such as font size, color , etc. , using the method set ?
------ eference --------------------------------------- < br> Well , I was like , directly controlled by Theme overall style , if there exists a special individual settings , such as a button or directly to the textview style, which would also lay the foundation for future expansion , it is thought the style , and code logic separate , give the site css and html like ,
There is no way you can set a specific style direct it? If the direct write code that directly speak to the three upstairs to find the ID can be set , what can increase the skin after too cumbersome , you can set the style is not it? No, then how to do a better separation of code ? After the skin is easier to add ? Thank you again make a suggestion it !
------ eference --------------------------------------- < br> If the code is not directly set style
all styles extracted :
now probably thinking is : The Theme of the same type can be mounted under a few style ( a theme style have multiple button you can have more than you want to mount the Style for select ) android: buttonStyle like this . . Then I just need to select the appropriate code in the box , you can directly replace all styles , , so the idea feasible? Do tricks like him make a suggestion ah ~ !
------ eference --------------------------------------- < br> Results posted Results posted , this has to get a ~ whirring !
------ eference --------------------------------------- < br> seeking the truth ah !
------ eference --------------------------------------- < br> how to solve the landlord seeking the truth Thank
------ eference ------------------------- --------------
encountered the same problem ! How to solve the landlord ? Thank you

------ eference ------------------------------------ ---


strongly BS, TM you have come to ask questions , solve even the programs are not posted, engage JB wool , Lv egg stuff

I checked , it should be this:
textView.setTextAppearance (context, R.style.normal_button);
------ eference ----------------------- ----------------
contempt landlord . . .
------ eference --------------------------------------- < br> ah common contempt
------ eference ------------------------------- --------
specially Login to despise the landlord

没有评论:

发表评论