Title bar widget
AUTitleBar is a title bar widget that includes a back button, a title, a progress bar, a left button (with text and an icon), and a right button (with text and an icon).
Preview
By default, the AUTitleBar control has a white background:


API reference
/**
* Sets the drawable for a button.
* @param iconView
* @param resId
*/
public void setBtnImage(AUIconView iconView, int resId) ;
/**
* Sets the size and color of a button.
* @param iconView
* @param size
* @param color
*/
public void setIconFont(AUIconView iconView, int size, int color);
/**
* Gets the back button.
* @return
*/
public AUIconView getBackButton() ;
/**
* Gets the left button.
* @return
*/
public AURelativeLayout getLeftButton() ;
/**
* Gets the right button.
* @return
*/
public AURelativeLayout getRightButton() ;
/**
* Gets the progress spinner.
* @return
*/
public AUProgressBar getProgressBar() ;
/**
* Gets the title text view.
* @return
*/
public AUTextView getTitleText() ;
/**
* Gets the title container.
* @return
*/
public AURelativeLayout getTitleContainer() ;
/**
* Gets the title bar area.
* @return
*/
public AURelativeLayout getTitleBarRelative() ;
@Override
public void setBackgroundDrawable(Drawable backgroundDrawable) ;
/**
* Sets the rotation resource for the progress bar.
* @param progressDrawable
*/
public void setProgressBarDrawable(Drawable progressDrawable) ;
/**
* Sets the text and style of the title. To use default values, set parameters to null or 0.
* @param text
* @param textSize
* @param textColor
*/
public void setTitleText(String text, int textSize, int textColor) ;
/**
* Sets the title text.
* @param text
*/
public void setTitleText(String text) ;
/**
* Sets the resource, size, and color of the back button. If a parameter is null or 0, the default value is used.
* @param drawable
* @param size
* @param color
*/
public void setBackBtnInfo(Object drawable, int size, int color);
/**
* Sets the resource for the back button.
* @param drawable
*/
public void setBackBtnInfo(Object drawable);
/**
* Sets the resource, size, and color of the left button. If a parameter is null or 0, the default value is used.
* @param drawable
* @param size
* @param color
* @param isText
*/
public void setLeftBtnInfo(Object drawable, int size, int color, boolean isText);
/**
* Sets the resource for the left button.
* @param drawable
*/
public void setLeftButtonIcon(Drawable drawable);
public void setLeftButtonIcon(String unicode);
public void setLeftButtonText(String text);
/**
* Sets the color and size of the left button.
* @param size
* @param color
* @param isText
*/
public void setLeftButtonFont(int size, int color, boolean isText);
/**
* Sets the resource, size, and color of the right button. If a parameter is null or 0, the default value is used.
* @param drawable
* @param size
* @param color
* @param isText
*/
public void setRightBtnInfo(Object drawable, int size, int color, boolean isText) ;
/**
* Sets the resource for the right button.
* @param drawable
*/
public void setRightButtonIcon(Drawable drawable);
public void setRightButtonIcon(String unicode);
public void setRightButtonText(String text);
/**
* Sets the color and size of the right button.
* @param size
* @param color
* @param isText
*/
public void setRightButtonFont(int size, int color, boolean isText);
/**
* Starts the progress bar rotation.
*/
public void startProgressBar();
/**
* Stops the progress bar and makes it disappear.
*/
public void stopProgressBar() ;
/***
* Handles the default scroll gradient. The default height is used for totalHeight.
* @param currentHeight The current height.
*/
public void handleScrollChange(int currentHeight);
/***
* Handles the default scroll gradient.
*
* @param totalHeight The total height.
* @param currentHeight The current height.
*/
public void handleScrollChange(int totalHeight, int currentHeight) ;
/**
* Sets the icon color to white for use with a transparent background.
*/
public void setColorWhiteStyle();
/**
* Sets the icon color for use with a white background.
*/
public void setColorOriginalStyle();
/**
* Hides the back button.
*/
public void setBackButtonGone();
/**
* Adds a search box (read-only). This is for visual adjustment only.
* @param search
*/
public void setTitle2Search(String search);
/**
* Transforms the search box into a title.
*/
public void setSearch2Title();
/**
* Sets the search box to have black text on a white background.
*/
public void setSearchColorOriginalStyle();
/**
* Sets the search box to have white text on a transparent background.
*/
public void setSearchColorTransStyle();
/**
* Adds a red dot to the left icon.
* @param flagView
*/
public void attachFlagToLeftBtn(AUWidgetMsgFlag flagView);
/**
* Adds a red dot to the right icon.
* @param flagView
*/
public void attachFlagToRightBtn(AUWidgetMsgFlag flagView) ;
/**
* Adds a red dot to the targetView.
* @param targetView
* @param flagView
*/
public void attachFlagView(AURelativeLayout container, View targetView, AUWidgetMsgFlag flagView);Custom properties
Property name | Description | Type |
backgroundDrawable | The background of the entire title bar. | reference |
backIconColor | The color of the back arrow. | color, reference |
titleText | The title text. | string, reference |
titleTextSize | The font size of the title. | dimension, reference |
titleTextColor | The font color of the title. | color, reference |
leftIconResid | The PNG or JPG ID of the left icon. | reference |
leftIconUnicode | The Unicode for the left icon. | string, reference |
leftIconColor | The color of the left icon. | color, reference |
leftIconSize | The size of the left icon. | dimension, reference |
leftText | The text on the left. | string, reference |
leftTextColor | The color of the text on the left. | color, reference |
leftTextSize | The size of the text on the left. | dimension, reference |
rightIconResid | The PNG or JPG ID of the right icon. | reference |
rightIconUnicode | The Unicode for the right icon. | string, reference |
rightIconColor | The color of the right icon. | color, reference |
rightIconSize | The size of the right icon. | dimension, reference |
rightText | The text on the right. | string, reference |
rightTextColor | The color of the text on the right. | color, reference |
rightTextSize | The size of the text on the right. | dimension, reference |
Code examples
In the following examples, the reference path for the aui prefix is xmlns:aui="http://schemas.android.com/apk/res/com.alipay.mobile.antui".
Basic usage
<com.alipay.mobile.antui.basic.AUTitleBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
aui:aui_titleText="Title"
aui:aui_titleTextSize="@dimen/AU_TEXTSIZE2"
aui:aui_titleTextColor="#f64219"
aui:leftIconUnicode="@string/iconfont_user_setting"
aui:rightText="Test2"/>![]()
Transparent on scroll
<com.alipay.mobile.antui.basic.AUTitleBar
android:id="@+id/title_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
aui:rightIconUnicode="@string/iconfont_user_setting"
aui:aui_titleText="Transparent Title Test" />titleBar.handleScrollChange(testImg.getMeasuredHeight(), 0);
testScroll.setScrollViewListener(new AUScrollViewListener() {
@Override
public void onScrollChanged(ScrollView scrollView, int x, int y, int oldx, int oldy) {
titleBar.handleScrollChange(y);
}
});
Title with red dot
<com.alipay.mobile.antui.basic.AUTitleBar
android:id="@+id/progress_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
aui:aui_titleText="Title with Refresh"
aui:leftIconUnicode="@string/iconfont_scan"
aui:rightIconUnicode="@string/iconfont_more"/>AUTitleBar processBar = (AUTitleBar) findViewById(R.id.progress_title);
processBar.startProgressBar();
WidgetMsgFlag j = new WidgetMsgFlag(this);
j.showMsgFlag();
processBar.attachFlagToLeftBtn(j);
WidgetMsgFlag i = new WidgetMsgFlag(this);
i.showMsgFlag(12);
processBar.attachFlagToRightBtn(i);![]()