Are there buttons like these built into the Android that Devs can use?
I want to try to get nice buttons that will w开发者_开发知识库ork similar to tabs down the bottom of my app, but I am wondering if there are buttons like this built in:
It would make navigation better, and developing a lot easier & faster if they are.
Your example screenshot is showing a mostly-untouched stock Android 2.2 launcher. Since it's open source you can take a look at how it's done. Here's the layout file it uses.
Note the RelativeLayout at the bottom containing the three "hotseat" buttons. Each of them uses a custom style to get the appearance, those styles are defined here.
What you are showing in the picture is HTC Sense Launcher. It's an add-on and not part of core Android OS.
BTW it's easy to do custom transparent button like this. Let me know if you need any help with this.
Update:
Use this example to create a custom Dialog, that is not modal and is floating and transparent.
dialog = new Dialog(activityRequestingProgressDialog);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.progress_upload);
progressBar = (ProgressBar) dialog.findViewById(R.id.progressBar);
progressText = (TextView) dialog.findViewById(R.id.progressText);
progressText.setText("0 %");
progressText.setTextSize(18);
Button buttonCancel = (Button) dialog.findViewById(R.id.btnCancel);
buttonCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
cancelProgressDialog();
}
});
Window window = dialog.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.setGravity(Gravity.BOTTOM);
dialog.show();
And the dialog layout is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progressDialog"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="18sp"
android:padding="10dp"
android:text="@string/progress_title"/>
<LinearLayout android:id="@+id/progressDialog"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="10dp"
android:layout_centerVertical="true">
<ProgressBar android:id="@+id/progressBar"
android:layout_width="150dp"
android:layout_height="34dp"
android:paddingRight="10dp"
android:max="100"
android:progress="0"
android:fadingEdge="vertical"
style="?android:attr/progressBarStyleHorizontal"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/progressText"
android:paddingRight="10dp"/>
<Button android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dip"
android:text="@string/button_options_text"
android:textColor="@color/button_text_grey"
android:drawableTop="@drawable/button_options"
android:drawablePadding="-5dip"
android:background="@null"/>
</LinearLayout>
</LinearLayout>
This is an example of a progress dialog with progress bar, text and cancel button. You can easily change this to three buttons. Note that button is transparent with icon and text.
精彩评论