Mobile Video second day: implementation of the bottom menu

Source: Internet
Author: User

Below the main page, the actual effect of each button

The bottom of this place a few buttons, is actually a radiogroup, and Radiogroup's parent class is linearlayout.

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/9B/B8/wKioL1lmQIajtfk7AAA7oF44Sls279.png-wh_500x0-wm_ 3-wmp_4-s_3164136869.png "title=" qq picture 20170712232823.png "alt=" Wkiol1lmqiajtfk7aaa7of44sls279.png-wh_50 "/>

These buttons are actually Radiogroup's child button, and then set up the pictures and text. After clicking, toggle the text and the picture, to achieve the selected effect, similar to the CSS Mouse put up, set the hover property


1, Activity_main.xml

First look at the layout of the main page, for the time being only write the below this

<?xml version= "1.0"  encoding= "Utf-8"? ><linearlayout xmlns:android= "http// Schemas.android.com/apk/res/android "               android:layout_width= "Match_parent"                android:layout_height= "Match_parent"                android:orientation= "vertical" >    <!--  Title bar-->    <!--framelayout -->    <framelayout         android:background= "#22000000"          android:id= "@+id/fl_main_content"         android:layout_ weight= "1"         android:layout_width= "Match_parent"          android: layout_height= "0DP"/>    <!-- RadioGroup-->    < Radiogroup        android:id= "@+id/rg_bottom_tag"          android:padding= "3DP"         android: Gravity= "center_vertical"         android:orientation= "Horizontal"         android:layout_width= "Match_parent"          android:layout_height= "Wrap_content" >         <radiobutton            android:id= "@+id/ Rb_video "            android:text=" local video              android:drawabletop= "@drawable/rb_video_ Drawable_selector "            style= "@style/bottom_tag_style"/>         <RadioButton             android:id= "@+id/rb_audio"              android:text= "Local Audio"             android:drawabletop = "@drawable/rb_audio_drawable_selector"              style= "@style/bottom_tag_style"/>        <radiobutton             android:id= "@+id/rb_net_video"              android:text= "Network Video"              android:drawabletop= "@drawable/rb_net_video_drawable_selector"             style= "@style/bottom_tag_style"/>         <radiobutton            android:id= "@+id/rb_net_audio"             android:text= "Network Audio"             android:drawabletop= "@drawable/rb_net_ Audio_drawable_selector "            style=" @style/ Bottom_tag_style "/>    </radiogroup></linearlayout>

Since many of the four buttons have the same properties, they are pulled out and placed in the style.xml as an external reference style.

It is important to note that each RadioButton Drawabletop this property, here is the display of the individual icons, referring to the various XML resources in the drawable, to achieve the selection and when not selected when the picture is displayed. , take a look at the local video to see a reference to this picture

<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_checked=" false "android:drawable=" @drawable/ic_tab_video "/> <item Android : State_checked= "true" android:drawable= "@drawable/ic_tab_video_press"/></selector>

When RadioButton is selected, the resource picture below is displayed, and the resource picture above is displayed when unchecked.


2, Style.xml

The common attributes of these several RadioButton are drawn out of the style, i.e. the botton_tag_style below

<resources>    <!-- Base application theme. -->     <style name= "Apptheme"  parent= "Theme.AppCompat.Light.DarkActionBar" >         <!-- Customize your theme here. -->         <item name= "Colorprimary" > @color/colorprimary</ Item>        <item name= "ColorPrimaryDark" > @color/ Colorprimarydark</item>        <item name= "ColorAccent" > @color/coloraccent</item>    </style>    <style  name= "Bottom_tag_style"  >        <!-- customize  your theme here. -->        <item name = "Android:layout_width" >wrap_Content</item>        <item name= "Android:layout_height" >wrap_content</item>        <item name= "Android: Button "> @android:color/transparent</item> <!--  This property ensures that the left circle of the RadioButton is hidden  -->         <item name= "Android:textcolor" > @drawable/rb_video_ Textcolor_selector</item>        <item name= "Android: TextSize ">10sp</item>        <item name=" Android: Drawablepadding ">3dp</item>        <item name=" Android:layout_gravity ">center_vertical</item>        < Item name= "Android:gravity" >center</item>        < Item name= "Android:layout_weight" &Gt;1</item> <!--  Make these four buttons equally wide  -->!     </style></resources>

3, Mainactivity.java

You need to instantiate these layouts here, and when you go to the main page by default, select the video button

package com.yuanlp.mobileplayer.activity;import android.app.activity;import android.os.bundle; import android.widget.framelayout;import android.widget.radiogroup;import  com.yuanlp.mobileplayer.r;/** *  Main Page  * Created by  Yuriping &NBSP;ON&NBSP;2017/7/12.  */public class MainActivity extends Activity{    private  framelayout fl_main_content;    private radiogroup rg_bottom_tag;      @Override     protected void oncreate (bundle  savedinstancestate)  {        super.oncreate (savedInstanceState);         setcontentview (R.layout.activity_main);         fl_main_content=  (framelayout)  findviewbyid (r.id.fl_main_content);         rg_bottom_tag=&nbSP; (radiogroup)  findviewbyid (R.id.rg_bottom_tag);         rg_ Bottom_tag.check (r.id.rb_video);   //Local video    &nbsp of the home page is selected by default;}}


Now that you have perfected the Loding page when you open the program and switch from the Loding page to the main page, the Home menu is displayed. The next blog will refine the main display area above the main menu

This article is from the "Yuangushi" blog, make sure to keep this source http://cm0425.blog.51cto.com/10819451/1946911

Mobile Video second day: implementation of the bottom menu

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.