开发者

Android TitleBar / NavBar?

开发者 https://www.devze.com 2023-01-03 16:39 出处:网络
I am not sure what the proper term is, but I am trying to add a \"TitleBar\" to the top of one of the windows in my App. Much like the Contacts App, I have several Tabs along the top of the screen. Wh

I am not sure what the proper term is, but I am trying to add a "TitleBar" to the top of one of the windows in my App. Much like the Contacts App, I have several Tabs along the top of the screen. When you select an item from the list, it loads the next Activity, but that Activity no long开发者_如何学Cer has the Tabs at the top of the screen.

I don't know if it is called a TitleBar or what. The Contacts App has this TitleBar along the top of the screen when you select a person from the list of Contacts.

I am trying to mimick the Grey Bar that says "George Washington"

Android TitleBar / NavBar?


The Contacts app is open source (as are most of the core Android system apps). I suggest checking it out and looking at the layout you want to emulate. In general, poking around a lot of that code is a good idea to get a handle on some best practices, or just to borrow a few tricks.

In this particular case, they're using a custom View called ContactHeaderWidget, which is actually a FrameLayout wrapping a TextView and Checkbox (styled to look like a star), along with the photo view (which has some special behavior to bind with the multiple contact source data on click and so on).

If you just want the look and not the functionality, though, just adding a LinearLayout with a GradientDrawable background containing an ImageView, a TextView, and a Checkbox styled as a star to your activity's layout should get you there a lot more easily without requiring custom widgets.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号