Dynamically move the control location in the XML file

Source: Internet
Author: User

<? XML version = "1.0" encoding = "UTF-8"?>

<Com. Android. launcher2define. draglayer
Xmlns: Android = "http://schemas.android.com/apk/res/android"
Xmlns: launcher = "http://schemas.android.com/apk/res/com.android.launcher2define"

Android: Id = "@ + ID/drag_layer"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">




<Com. Android. launcher2define. Workspace
Android: Id = "@ + ID/workspace"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: scrollbars = "horizontal"
Android: fadescrollbars = "true"
Launcher: defaultscreen = "0"

>
<Include Android: Id = "@ + ID/cell1" layout = "@ layout/workspace_screen"/>
<Include Android: Id = "@ + ID/cell2" layout = "@ layout/workspace_screen"/>
<Include Android: Id = "@ + ID/cell3" layout = "@ layout/workspace_screen"/>
<Include Android: Id = "@ + ID/cell4" layout = "@ layout/workspace_screen"/>
<Include Android: Id = "@ + ID/cell5" layout = "@ layout/workspace_screen"/>
</COM. Android. launcher2define. workspace>





<Linearlayout
Android: Orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: paddingtop = "400dip"
>


<Linearlayout
Android: Orientation = "horizontal"
Android: layout_width = "fill_parent"
Android: layout_height = "400dip"
Android: paddingleft = "20dp"
Android: Id = "@ + ID/sort"
>
<Linearlayout
Android: layout_width = "142dp"
Android: layout_height = "275dp"
Android: Orientation = "vertical"
Android: layout_margintop = "3dp"
Android: Background = "@ drawable/applicationtype"
>
<! -- Office: 1 meshwork: 2 Amusement: 3 personal: 4 tools: 5 media: 6 latest: 7 -->
<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/textallapps"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "0"
Android: text = "@ string/allapps"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: layout_margintop = "10dp"
Android: textcolor = "@ color/color_default"
/>

<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/textoffice"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "1"
Android: text = "@ string/office"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: textcolor = "@ color/color_default"
/>
<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/textmedia"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "6"
Android: text = "@ string/Media"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: textcolor = "@ color/color_default"
/>
<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/textamusement"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "3"
Android: text = "@ string/amusement"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: textcolor = "@ color/color_default"
/>
<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/texttool"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "5"
Android: text = "@ string/tool"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: textcolor = "@ color/color_default"
/>
<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/textusually"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "-1"
Android: text = "@ string/Usually"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: textcolor = "@ color/color_default"
/>
<Com. Android. launcher2define. buttonappsorttype Android: layout_width = "wrap_content"
Android: layout_height = "35dp"
Android: gravity = "center_vertical | right"
Android: Id = "@ + ID/textrecent"
Android: Background = "@ drawable/chooseapptype"
Launcher: Sort = "7"
Android: text = "@ string/recent"
Android: textsize = "16dp"
Android: paddingright = "21dp"
Android: textcolor = "@ color/color_default"
/>
</Linearlayout>
<Linearlayout
Android: Orientation = "vertical"
Android: layout_width = "244dp"
Android: layout_height = "fill_parent"
Android: paddingtop = "3dp"
Android: visibility = "visible"
Android: layout_marginleft = "20dp"

> <Com. Android. launcher2define. all1_view
Android: Id = "@ + ID/all_assist_view"
Android: layout_width = "fill_parent"
Android: layout_height = "365dp"
Android: visibility = "visible"
Android: scrollbarstyle = "outsideinset"
Android: drawselectid Top = "false"
Android: listselector = "@ drawable/grid_selector"
Android: scrollbars = "NONE"
Android: numcolumns = "4"
Android: layout_margintop = "3dp"
/>
</Linearlayout>

</Linearlayout>
</Linearlayout>



<Linearlayout
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: Orientation = "vertical"
Android: layout_gravity = "right | center_vertical"
Android: paddingtop = "270dp"
Android: paddingleft = "420dp"
>
<Com. Android. launcher2define. deletezone
Android: Id = "@ + ID/delete_zone"
Android: layout_width = "50dp"
Android: layout_height = "50dp"
Android: src = "@ drawable/delete_appcation"
Android: focusable = "true"
Android: clickable = "true"
Android: visibility = "gone"
/>
<Com. Android. launcher2define. uninstallzone
Android: Id = "@ + ID/uninstallapps"
Android: layout_width = "50dp"
Android: layout_height = "50dp"
Android: src = "@ drawable/uninstall_appcation"
Android: layout_margintop = "30dp"
Android: focusable = "true"
Android: clickable = "true"
Android: visibility = "gone"
/>
</Linearlayout>





<! -- Five screen button
Android: gravity = "center_horizontal" -->
<Linearlayout
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
<Linearlayout
Android: Id = "@ + ID/fivescreen"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: paddingtop = "350dip"
Android: gravity = "center_horizontal"
>
<Imagebutton
Android: Id = "@ + ID/One"
Android: layout_width = "39px"
Android: layout_height = "40px"
Android: src = "@ drawable/screen"
Android: focusable = "true"
Android: clickable = "true"
Android: padding = "25dp"
Android: Background = "#00000000"
Android: layout_marginleft = "10dip"
/>


<Imagebutton
Android: Id = "@ + ID/Two"
Android: layout_width = "39px"
Android: layout_height = "40px"
Android: src = "@ drawable/screen"
Android: focusable = "true"
Android: clickable = "true"
Android: padding = "25dp"
Android: Background = "#00000000"
Android: layout_marginleft = "30dip"
/>

<Imagebutton
Android: Id = "@ + ID/three"
Android: layout_width = "39px"
Android: layout_height = "40px"
Android: src = "@ drawable/screen"
Android: focusable = "true"
Android: clickable = "true"
Android: padding = "25dp"
Android: Background = "#00000000"

Android: layout_marginleft = "30dip"

/>

<Imagebutton
Android: Id = "@ + ID/four"
Android: layout_width = "39px"
Android: layout_height = "40px"
Android: src = "@ drawable/screen"
Android: focusable = "true"
Android: clickable = "true"
Android: padding = "25dp"
Android: Background = "#00000000"

Android: layout_marginleft = "30dip"

/>

<Imagebutton
Android: Id = "@ + ID/five"
Android: layout_width = "39px"
Android: layout_height = "40px"
Android: src = "@ drawable/screen"
Android: focusable = "true"
Android: clickable = "true"
Android: padding = "25dp"
Android: Background = "#00000000"
Android: layout_marginleft = "30dip"

/>

</Linearlayout>
</Linearlayout>






</COM. Android. launcher2define. draglayer>

 

 

 

 

 

 

 

 

 

Public void onclick (view arg0 ){
If (missortviewvisble)
{
/* Mcelllayout. requestlayout ();
Mcelllayout1.requestlayout ();
Mcelllayout2.requestlayout ();
Mcelllayout3.requestlayout ();
Mcelllayout4.requestlayout ();*/

Mworkspace. setaxispadding (false );
Muninstallzone. setvisibility (view. Gone );
Mdeletezoneapp. setvisibility (view. Gone );
Mallappsgrid. setvisibility (view. Gone );
Mallappsgrid. startanimation (animationutils. loadanimation (getapplicationcontext (), R. anim. app_starting_exit ));
Mbtnallapp. setvisibility (view. Gone );
Mbtnusuallyapp. setvisibility (view. Gone );
Mbtnrecentapp. setvisibility (view. Gone );
Mbtnofficeapp. setvisibility (view. Gone );
Mbtnmediaapp. setvisibility (view. Gone );
Mbtnamusementapp. setvisibility (view. Gone );
Mbtntoolapp. setvisibility (view. Gone );
Mviewsort. setvisibility (view. Gone );
If (getresources (). getconfiguration (). Orientation = activityinfo. screen_orientation_portrait)
{
// Port
Linearlayout. layoutparams Lp = (linearlayout. layoutparams) findviewbyid (R. Id. fivescreen). getlayoutparams ();
LP. topmargin = 365;
LP. leftmargin = 10;
Findviewbyid (R. Id. fivescreen). setlayoutparams (LP );

} Else
{
// Land
Linearlayout. layoutparams Lp = (linearlayout. layoutparams) mimagebuttonone. getlayoutparams ();
LP. leftmargin = 50;
Mimagebuttonone. setlayoutparams (LP );
}
} Else
{
Mworkspace. setaxispadding (true );
Mviewsort. setvisibility (view. Visible );
Mallappsgrid. setvisibility (view. Visible );
Mallappsgrid. startanimation (animationutils. loadanimation (getapplicationcontext (), R. anim. activity_close_enter ));
Mbtnallapp. setvisibility (view. Visible );
Mbtnusuallyapp. setvisibility (view. Visible );
Mbtnrecentapp. setvisibility (view. Visible );
Mbtnofficeapp. setvisibility (view. Visible );
Mbtnmediaapp. setvisibility (view. Visible );
Mbtnamusementapp. setvisibility (view. Visible );
Mbtntoolapp. setvisibility (view. Visible );
If (getresources (). getconfiguration (). Orientation = activityinfo. screen_orientation_portrait)
{
// Port

Linearlayout. layoutparams Lp = (linearlayout. layoutparams) findviewbyid (R. Id. fivescreen). getlayoutparams ();
LP. topmargin = 0;
LP. leftmargin = 10;
Findviewbyid (R. Id. fivescreen). setlayoutparams (LP );

} Else
{
// Land
Linearlayout. layoutparams Lp = (linearlayout. layoutparams) mimagebuttonone. getlayoutparams ();
LP. leftmargin = 190;
Mimagebuttonone. setlayoutparams (LP );
}
}
Missortviewvisble =! Missortviewvisble;

}
});

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.