Android QQ New User Registration interface drawing _android

Source: Internet
Author: User

First look at the effect chart:

Problem:

1. Drop down list (because you haven't seen this yet ...) )

2, the title bar display problems

3, the button to Enable settings

..........

Here's the code:

Layout Fragment_main (Issue 1)

<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http:// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android: Focusable= "true" android:focusableintouchmode= "true" android:background= "#F7F7F9" tools:context= " Com.dragon.android.qqregist.mainactivity$placeholderfragment "> <button android:id=" @+id/button2 "Android : layout_width= "wrap_content" android:layout_height= "50DP" android:layout_alignparenttop= "true" Android:backgro Und= "#ffffff" android:drawableleft= "@drawable/aa" android:text= "@string/button2" android:textcolor= "#1CBAF5" > <textview android:id= "@+id/textview2" android:layout_width= "Match_parent" android:layout_height= "50 DP "android:layout_alignbaseline=" @+id/button2 "android:layout_alignbottom=" @+id/button2 "android:background=" #ffffff "android:gravity=" center "android:text=" @string/pagename"Android:textcolor=" #1CBAF5 "/> <linearlayout android:id=" @+id/linear "Android:layout_width=" mat Ch_parent "android:layout_height=" wrap_content "android:orientation=" horizontal "android:layout_below=" @id/but
    Ton2 "android:paddingtop=" 30DP "android:paddingbottom=" 20DP "> <spinner android:id=" @+id/spinner1 " Android:layout_width= "0DP" android:layout_height= "wrap_content" android:background= "@drawable/bg_spinner" droid:layout_weight= "1" android:entries= "@array/country"/> <edittext android:id= "@+id/edittext1" Droid:layout_width= "0DP" android:layout_height= "Wrap_content" android:layout_weight= "2" android:background= "@ Drawable/bg_edittext "android:ems=" android:inputtype= "Phone" android:hint= "@string/innum" Android:colo R= "#000000" android:textsize= "15SP" > </EditText> </LinearLayout> <button android:id= "@ +id/button1 "Android: layout_width= "match_parent" android:layout_height= "wrap_content" android:layout_marginleft= "10DP" Android:lay out_marginright= "10DP" android:layout_below= "@id/linear" android:enabled= "false" android:background= "@drawable /bg_button "android:text=" @string/button "android:gravity= Center" android:textcolor= "#FFFFFF"/> <c
    Heckbox android:id= "@+id/checkbox1" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_margintop= "10DP" android:layout_marginleft= "10DP" android:layout_below= "@id/button1" Android : text= "@string/sure" android:textsize= "12SP" android:textcolor= "#A6A6A7"/> <textview android:id= "@+i D/textview1 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "Android:layout_alignBase" Line= "@+id/checkbox1" android:layout_alignbottom= "@+id/checkbox1" android:layout_marginleft= "10DP" Android:lay Out_torightof= "@+id/checKBox1 "android:autolink=" All "android:text=" @string/protocol "android:textsize=" 12sp "/> </relativelayo

 Ut>

Background before and after EditText, Spinner and Button modifications
1.bg_edittext

<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
  
  <stroke android:width=" 1px "android:color=" #BEBEBE "/>
  
  <solid android:color=" #FFFFFF "/>
  
  <padding 
    android:left=" 10DP "
    android:top=" 10DP "
    android:bottom=" 10DP "/>

< /shape>

2.bg_spinner

<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
  
  <stroke android:width=" 1px "android:color=" #BEBEBE "/>
  
  <solid android:color=" # FFFFFF "/>
  
  <padding 
    android:left=" 10DP "
    android:top=" 10DP "
    android:bottom=" 10DP "/>

</shape>

3.bg_button

<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
  
  <solid android:color=" #808080 "/>
  
  <corners android:radius=" 10DP "/>
  
  < padding 
    android:top= "10DP" 
    android:bottom= "10DP"/>

</shape>

4.bg_buttin_change

<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android ">
  
  <solid android:color=" #1CBAF5 "/>
  
  <corners android:radius=" 10DP "/>
  
  < padding 
    android:top= "10DP" 
    android:bottom= "10DP"/>

</shape>

Spinner Drop-down Data arrays

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
  <string-array name= "Country" >
    <item > China   +86</item>
    <item > Hongkong   +852</item>
    <item > Macau   +853</ Item>
    <item > Taiwan   +886</item>
    <item > Japan   +81</item>
    <item > USA   +1</item>
    <item > UK   +44</item>
  </string-array>
</ Resources>

Background of title bar (Issue 2--discard)

 <?xml version= "1.0" encoding= "Utf-8"?> <resources "xmlns:android=" Schemas.android.com/apk/res/android "> <style name=" bg_title "parent=" Android:theme "> <item name=" Andro Id:windowtitlebackgroundstyle "> @style/titleground</item> <item name=" Android:windowtitlestyle ">@
  
  style/windowtitlestyle</item> <item name= "android:windowtitlesize" >40dp</item> </style>
  
  <style name= "Titleground" > <item name= "android:background" > #FFFFFF </item> </style> <style name= "Windowtitlestyle" > <item name= "android:text" > @string/pagename</item> <item name= "Android:textcolor" > #1CBAF5 </item> <item name= "android:paddingtop" >2dp</item> <item name= "
   
Android:paddingbottom ">2dp</item> <item name=" android:textsize ">20sp</item> </style> </resources> 

Question 2 substitution method: Hide the title bar--Add in Androidmanifest--android:theme= "@android: Style/theme.notitlebar" >

Mainactivity (question 3)

Package com.dragon.android.qqregist;
Import Android.annotation.SuppressLint;
Import android.app.Activity;
Import Android.graphics.Color;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.widget.AdapterView;
Import Android.widget.AdapterView.OnItemSelectedListener;
Import Android.widget.Button;
Import Android.widget.CheckBox;
Import Android.widget.CompoundButton;
Import Android.widget.CompoundButton.OnCheckedChangeListener;
Import Android.widget.EditText;
Import Android.widget.Spinner;

Import Android.widget.Toast;
  public class Mainactivity extends activity {private Spinner Spinner = null;
  Private EditText EditText1;
  Private Button button2;
  Private Button button1;

  Private CheckBox CheckBox1;
    @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);

    Setcontentview (R.layout.fragment_main);
    Spinner = (spinner) Findviewbyid (R.id.spinner1);
    Spinner.setselection (0); EditText1 = (edittext) findviewByid (R.ID.EDITTEXT1);
    Edittext1.sethinttextcolor (Color.gray);
    Button2 = (Button) Findviewbyid (R.id.button2);
    Set the space of the top Button2.bringtofront ();

    Button1 = (Button) Findviewbyid (R.id.button1); Spinner Select Listener Event Spinner.setonitemselectedlistener (new Onitemselectedlistener () {@Override//parent current S Pinner Pos/id Selected value location/Line public void onitemselected (adapterview<?> parent, view view, int pos, long I
        d) {//Get String-array string[] Country = getresources (). Getstringarray (R.array.country);
      Toast.maketext (Mainactivity.this, "you choose:" + Country[pos], toast.length_short). Show (); @Override public void onnothingselected (adapterview<?> parent) {//Another interface Callbac
    K}});
    CheckBox1 = (CheckBox) Findviewbyid (r.id.checkbox1); Checkbox1.setoncheckedchangelistener (New Oncheckedchangelistener () {@Override @SuppressLint ("NEwapi ") public void oncheckedchanged (Compoundbutton view, Boolean inchecked) {button1.setenabled (inchecked)
        ; if (!inchecked) {//Set button background Button1.setbackground (Getresources (). Getdrawable (r.drawabl
        E.bg_button));
        else {Button1.setbackground (Getresources (). getdrawable (R.drawable.bg_button_change));
  }
      }
    });

 }
}

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.