In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you what are the application skills of Android. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Writing Android in the simulator can help us achieve many of the functions we want. In practical application, we can accumulate experience and sum up various skills to facilitate our application. Here is a detailed summary of several commonly used Android application skills.
The use of 1.Drawable
Drawable most often handles things that are drawn to the screen as a type of resource recycling; the Drawable class provides a generic API to handle a basic visual resource that can take many forms. (it's a little abstract) to put it bluntly, it is to get the parameters under res.
Example: change TextView text color-quote Drawable color Changshu and background color
Color.xml under values
Xml code
< ?xml version="1.0" encoding="utf-8" ?> < resources> < drawable name="darkgray"># 808080FF
< /drawable> < drawable name="white"># FFFFFFFF
< /drawable> < /resources> < ?xml version="1.0" encoding="utf-8" ?> < resources> < drawable name="darkgray"># 808080FF
< /drawable> < drawable name="white"># FFFFFFFF
< /drawable> < /resources>Set the background color of the text box
Java code
Resources resources =
GetBaseContext () .getResources ()
Drawable HippoDrawable =
Resources.getDrawable (R.drawable.white)
MTextView01.setBackgroundDrawable (HippoDrawable)
Resources resources = getBaseContext () .getResources ()
Drawable HippoDrawable =
Resources.getDrawable (R.drawable.white)
MTextView01.setBackgroundDrawable (HippoDrawable)
two。 Get the screen size of the phone
Java code
DisplayMetrics dm = new DisplayMetrics (); getWindowManager (). GetDefaultDisplay (). GetMetrics (dm); Stirng width = dm.widthPixels; Stirng heiht = dm.heightPixels; DisplayMetrics dm = new DisplayMetrics (); getWindowManager (). GetDefaultDisplay (). GetMetrics (dm); Stirng width = dm.widthPixels; Stirng heiht = dm.heightPixels
3.Android style mechanism
Just add a Style. Can a Style realize the display style of the control? Android's Style mechanism is really powerful.
Example:
Xml code
< ?xml version="1.0" encoding="utf-8" ?>-
< resources>-
< style name="DavidStyleText1"> < item name="android:textSize">18sp
< /item> < item name="android:textColor"># EC9237
< /item> < /style>-
< style name="DavidStyleText2"> < item name="android:textSize">14sp
< /item> < item name="android:textColor"># FF7F7C
< /item> < item name="android:fromAlpha">0.0
< /item> < item name="android:toAlpha">0.0
< /item> < /style> < /resources> < ?xml version="1.0" encoding="utf-8" ?>-
< resources>-
< style name="DavidStyleText1"> < item name="android:textSize">18sp
< /item> < item name="android:textColor"># EC9237
< /item> < /style>-
< style name="DavidStyleText2"> < item name="android:textSize">14sp
< /item> < item name="android:textColor"># FF7F7C
< /item> < item name="android:fromAlpha">0.0
< /item> < item name="android:toAlpha">0.0
< /item> < /style> < /resources>Xml code
< ?xml version="1.0" encoding="utf-8" ?>-
< LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:background="@drawable/white" android:orientation= "vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">-
< !-- 应用模式1的TextView --> < TextView style="@style/DavidStyleText1" android:layout_width="fill_parent" android:layout_height= "wrap_content" android:gravity="center_vertical| center_horizontal" android:text="@string/str_text_view1" />-
< !-- 应用模式2的TextView --> < TextView style="@style/DavidStyleText2" android:layout_width="fill_parent" android:layout_height= "wrap_content" android:gravity="center_vertical| center_horizontal" android:text="@string/str_text_view2" /> < /LinearLayout>These are the Android application skills that Xiaobian shared with you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.