Android project development practice (1) -- menu BAR implementation on the top of the home page, Android bar

Source: Internet
Author: User

Android project development practice (1) -- menu BAR implementation on the top of the home page, Android bar

From today on, I will start writing a horoscope project by myself. The horoscope data source uses the constellation data of MYAPI, and the client implements it on its own.

This series mainly focuses on the layout presentation of the main interface in the project and the analysis of difficulties in some projects. As I have just learned about Android, please be considerate when making bricks.

First, let's talk about the implementation of BAR at the top of the homepage.

As far as I can see, the current APP will contain a BAR at the top, which is mainly used for prompt and navigation,

First, let's look at the actual results.


How can this effect be achieved?

The specific method is to nest a top navigation menu layout in the page layout.

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <RelativeLayout        android:id="@+id/headerlayout"        android:layout_width="fill_parent"        android:layout_height="45.0dip"        android:background="@color/title_color" >        <TextView            android:id="@+id/title"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerHorizontal="true"            android:layout_centerVertical="true"            android:text="@string/home"            android:textColor="#ffffffff"            android:textSize="20.0sp" />    </RelativeLayout></RelativeLayout>
Android: layout_centerHorizontal = "true" android: layout_centerVertical = "true" indicates that the TextView is displayed in the center. After this is done, you can load the layout in the OnCreate method of the Activity.

The code of the Activity is as follows:

protected void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          this.requestWindowFeature(Window.FEATURE_NO_TITLE);        setContentView(R.layout.main);  //        initComponent();    }  





In Android 411, how does one set a drop-down menu with transparent background?

As the Android system is updated and upgraded, many special features are added, and the drop-down menu background is transparent. The following uses Android 4.1.1 as an example, how to customize the transparent background of the drop-down menu! Generally, the drop-down menu of Android 4.1.1 is black. The following describes how to make the custom drop-down menu background transparent under Android 4.1.1. Of course, you can also change the drop-down menu to beautiful women and scenery. Here we will mainly teach you how to operate it! Specific setting method: 1. Prepare a 450*580 pngformat for the image you need to decompress systemui.apk; 3. Copy the prepared image to res \ drawable-xhdpi. Here we will change it to android.tgbus.com. 4. Open res \ layout \ tw_status_bar_expanded.xml; 5. Change android: background = "@ drawable/status_bar_background of the first line to android: background =" @ drawable/52 samsung "4256、, and use winrarto open systemui.apk; 7. Pull the image to res \ drawable-xhdpi and select storage mode. 8. Pull the edited tw_status_bar_expanded.xml to res \ layout \ and select storage mode; 9. Change the edited resource S. arsc pull to systemui.apk save type select storage 1_10.pdf copy the modified systemui.apk to system/app replace; 11. Restart the mobile phone; OK, after restarting the mobile phone, you can use the custom drop-down menu or background transparent drop-down menu! No Android phone users!

Actionbar operation items for Android Development

The android developer webpage contains a detailed article on actionbar design. We recommend that you check.

1. actionbar is the same as the drop-down menu.
2. The actionbar belongs to the application. As long as the fragment is converted, invalidateOptionsMenu (); the menu and actionbar will be built again.
3. onPrepareOptionsMenu () is the place where the actionbar and drop-down menu are built.

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.