1. In some of the QQ app is pop up a translucent search box, in fact, this effect is a lot of methods, custom a dialog, or directly to the background of the activity into translucent can also.
Here's how to turn activity into translucent. As follows:
2. The code is as follows:
Add a custom theme to the Styles.xml file
1 <stylename= "Mytranspaent">2 3 <Itemname= "Android:windowbackground">@color/transparent_background</Item> 4 <Itemname= "Android:windownotitle">True</Item> 5 <Itemname= "Android:windowistranslucent">True</Item> 6 <Itemname= "Android:windowanimationstyle">@+android:style/animation.translucent</Item> 7 </style>
Activity of the Search interface:
1 Public classSecondactivityextendsActivity {2 3 @Override4 protected voidonCreate (Bundle savedinstancestate) {5 Super. OnCreate (savedinstancestate);6 Setcontentview (r.layout.activity_second);7 }8 9 @OverrideTen Public BooleanOncreateoptionsmenu (Menu menu) { One //inflate the menu; This adds items to the action bar if it is present. A getmenuinflater (). Inflate (R.menu.second, menu); - return true; - } the - @Override - Public Booleanontouchevent (Motionevent event) { - + Switch(Event.getaction ()) { - CaseMotionevent.action_down: +Secondactivity. This. Finish (); A Break; at - default: - Break; - } - - return Super. Ontouchevent (event); in } - to}
Activity_second.xml file:
1 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:orientation= "Horizontal"6 Tools:context=". Secondactivity " >7 8 <EditText9 Android:id= "@+id/ed"Ten Android:layout_width= "Wrap_content" One Android:layout_height= "Wrap_content" A Android:layout_weight= "1.0" - Android:background= "#F8F8FF" - Android:drawableleft= "@drawable/ic_search_normal" the Android:hint= "Please enter what you want to query" - Android:textcolor= "#000033" /> - - </LinearLayout>
Inside the main interface is a button that pops up the activity.
1 Public classMainactivityextendsActivity {2 3 @Override4 protected voidonCreate (Bundle savedinstancestate) {5 Super. OnCreate (savedinstancestate);6 Setcontentview (r.layout.activity_main);7 8Findviewbyid (R.id.button01). Setonclicklistener (NewOnclicklistener () {9 Ten @Override One Public voidOnClick (View v) { AIntent i =NewIntent (); -I.setclass (mainactivity. This, Secondactivity.class); - startactivity (i); the } - }); - - } + -}
The key is to add theme to the popup activity in the Manifest.xml file.
1 < Activity 2 Android:name = "Com.example.compass.SecondActivity" 3 android:label= "@string/title_activity_second"4 android:theme = "@style/mytranspaent">5 </activity >
SOURCE download
Android Transparent pop-up search box