Android Faux today headlines title bar effect

Source: Internet
Author: User

have been learning Android application development for some time, the main basic knowledge involved in application development has been a certain understanding of the learning process written in the blog was I organized a column "Android Application Development Foundation." But basically the code is a demo demo of a single point of knowledge, which is far from a complete product. To have the ability to develop complex product-level applications, the best way to emulate the good applications developed by others is to master the basics of application development. In The imitation of the gradual, the programmer's perspective to see how each app is implemented, it has any advantages and disadvantages, and to promote themselves. Model other people's application is actually a kind of development of learning means, because if you go to develop, no UI no interaction process, then it may be difficult to start, when there are other people's interaction process and some resources, you can go to their own thinking if the implementation of relevant functions, how to achieve similar effects. Maybe your method is not so perfect, the implementation effect is not as brilliant as the original, but these are all with your thoughts, this is enough.

Today's headline news client is one of my most commonly used Android apps, and it's a good choice to imitate goals. This series of articles will be progressive to achieve the title bar effect of today's headlines.

The title bar of today's headline is not in the title bar area defined by the Android system, but attaches it to the acitivity Contentview. So the first thing to remove the Android system title bar, the method is as follows:
Modify the Style.xml file inside the \res\values
Add an entry under the Apptheme theme
<item name= "Android:windownotitle" >true</item>

Example: Toutiaotitlebardemo
Operating effect:

Layout view hierarchy:


Code Listing:
Style resource file: Styles.xml
<resources> <!--Base application theme, dependent on API level.    This theme are replaced by Appbasetheme from Res/values-vxx/styles.xml on newer devices. --<style name= "Appbasetheme" parent= "Android:Theme.Light" > <!--Theme customizations av Ailable in newer API levels can go in res/values-vxx/styles.xml, while customizations related to BAC        Kward-compatibility can go here. -</style> <!--application theme.  --<style name= "Apptheme" parent= "Appbasetheme" > <!--all customizations that is not specific to a Particular api-level can go here. --<item name= "Android:windownotitle" >true</item> </style> <style name= "Main_title_b Ar_style "> <item name=" android:background "> @drawable/bg_titlebar_main</item> <item name=" a Ndroid:layout_width ">fill_parent</item> <item name=" Android: Layout_height "> @dimen/title_bar_height</item> </style></resources> 

Layout file: Activity_main.xml

<relativelayout android:id= "@+id/main_layout" android:background= "@color/activity_bg_color" Android:layout_wid Th= "Fill_parent" android:layout_height= "fill_parent" xmlns:android= "Http://schemas.android.com/apk/res/android" &    Gt <relativelayout android:id= "@+id/title_bar" style= "@style/main_title_bar_style" > <framelayout android:id=             "@+id/top_head_container" android:paddingleft= "10.0dip" android:paddingright= "10.0dip" Android:layout_width= "Wrap_content" android:layout_height= "Fill_parent" > <imageview android: Layout_gravity= "center_vertical" android:id= "@+id/top_head" android:contentdescription= "@s Tring/app_name "android:background=" @drawable/bg_head "android:src=" @drawable/default_round _head "android:padding=" 2.0dip "android:layout_width=" @dimen/head_size "and Roid:layout_height= "@dImen/head_size "android:scaletype=" Fitxy "/> </FrameLayout> <imageview android:g            ravity= "center" android:id= "@+id/top_more" android:contentdescription= "@string/app_name" Android:layout_width= "Wrap_content" android:layout_height= "Fill_parent" Android:layout_marginrig ht= "12.0dip" android:src= "@drawable/right_drawer" android:scaletype= "Centerinside" and Roid:layout_alignparentright= "true" android:layout_centervertical= "true"/> <relativelayout Andro             Id:id= "@+id/title_click_layout" android:paddingleft= "13.0dip" android:layout_width= "Wrap_content" android:layout_height= "Fill_parent" android:layout_centerinparent= "true" > <framel Ayout android:id= "@+id/title_parent" android:layout_width= "Wrap_content" android:layout_he     ight= "Wrap_content"            Android:layout_centervertical= "true" > <imageview android:layout_gravity= "Center"                    Android:id= "@+id/title_recent" android:contentdescription= "@string/app_name" Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" and                 roid:src= "@drawable/title"/> </FrameLayout> <imageview android:id= "@+id/top_refresh" android:contentdescription= "@string/app_name" android:padding= "3.0dip" Androi D:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/ Refreshicon_titlebar "android:layout_torightof=" @id/title_parent "Android:layout_centerver Tical= "true"/> </RelativeLayout> </RelativeLayout></RelativeLayout>




Android Faux today headlines title bar effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.