# TitleLayout
**Repository Path**: applibgroup/TitleLayout
## Basic Information
- **Project Name**: TitleLayout
- **Description**: Versatile, universal, can be implemented in the layout or using Java code title bar; support immersive status bar; support title bar click, double click; support left back button does not need to manually implement page return; support left button, middle title, right button click Left support picture + text, separate picture, separate text; right side support separate picture, separate text, etc.
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-12-16
- **Last Updated**: 2022-01-04
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# TitleLayout
Multi-functional, universal, can be implemented in the layout or using Java code to achieve the title bar; support the left back button (no need to manually implement page return), the left side supports pictures + text, pictures, text; the right side Support pictures, text, etc.

### Source
---
This library has been inspired by [SiberiaDante/TitleLayout](https://github.com/SiberiaDante/TitleLayout)
### Integration
---
**From Source**
1. For using TitleLayout module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
```groovy
implementation project(path: ':titlelayout')
```
2. For using TitleLayout module in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
```groovy
implementation fileTree(dir: 'libs', include: ['*.har'])
```
## Use in layout:
```xml
```
## Use Java code:
```java
final TitleBarLayout titleBarLayout = (TitleBarLayout) findComponentById(ResourceTable.Id_title_layout_one);
titleBarLayout.setIsLeftBackView(true);
titleBarLayout.setTitleLayoutBackground(Color.BLUE);
titleBarLayout.setRightImageClickListener(new Component.ClickedListener() {
@Override
public void onClick(Component view) {
new ToastDialog(MainAbility.this).setText("The picture on the right was clicked").show();
}
});
titleBarLayout.setTitleClickListener(new OnMultiTouchListener(new TitleLayoutListener() {
@Override
public void onTitleClickListener() {
new ToastDialog(MainAbility.this).setText("Title was clicked").show();
}
@Override
public void onTitleDoubleClickListener() {
new ToastDialog(MainAbility.this).setText("Title was double clicked").show();
}
}));
```
## Key note:
* If the left text or button is the return key, just use the following code in the layout:
```
dante:d_is_back_view="true"
```
* Or in Java code:
```
titleLayout.setIsLeftBackView(true)
```
* There is no need to set onClickListener, this.finish, etc.; if you have special needs, you can set the attribute to false to implement the method:
```
setLeftClickListener(OnClickListener listener)
```
#### Other attribute description
#### Attributes in xml:
| xml Attributes |
Property description |
| d_left_image |
Left image resources |
| d_left_image_width |
Left picture widte (high to match the father layout) |
| d_left_image_padding_start |
Left picture left margins |
| d_left_image_padding_end |
Left picture right margins |
| d_left_text |
Left text resources |
| d_left_text_size |
Left text size |
| d_left_text_color |
Left text color (default black) |
| d_left_text_style |
Set text style (Normal | Bold) |
| d_left_text_padding_start |
Left word left margins |
| d_left_text_padding_end |
Left word right margins |
| d_title_text |
Intermediate header text resources |
| d_title_size |
Intermediate title text size |
| d_title_color |
Intermediate header text color (default black) |
| d_title_style |
Set text style (normal | bold) |
| d_subtitle_text |
Intermediate subtitle text resources |
| d_subtitle_size |
Intermediate subtitle text size |
| d_subtitle_color |
Intermediate subtitle text color (default black) |
| d_subtitle_style |
Set text style (normal | bold) |
| d_right_text |
Right text resources |
| d_right_text_color |
Right text color |
| d_right_text_size |
Right text size |
| d_right_text_style |
Set text style (bormal | bold) |
| d_right_text_padding_end |
Right text distance from the right |
| d_right_text_padding_start |
Right text distance from the left |
| d_right_image |
Right image resources |
| d_right_image_width |
Width of the right image |
| d_right_image_padding_end |
Right image distance from the right |
| d_right_image_padding_start |
Right image distance from the left |
| d_line_height |
The bottom horizontal line height of the title column (recommended units using PX) |
| d_line_background |
Title bar bottom horizontal line background color (default black) |
| d_title_layout_height |
Title bar overall height |
| d_title_layout_background |
Title bar overall background color |
| d_is_back_view |
Whether the left text and the image is a return button, if it is returned, come back to the previous page function |
---
#### Java code
| Java code method |
Java code method description |
| setTitle(CharSequence title) |
Set the title resource |
| setTitleSize(int titleSize) |
Set the title font size |
| setTitleColor(int titleColor) |
Set the title font color |
| setTitleStyle(String title, int titleSize, int titleColor) |
Set the title resource, text size, text color |
| setSubTitle(CharSequence title) |
Set the subtitle resource |
| setSubTitleSize(int titleSize) |
Set the subtitle font size |
| setSubTitleColor(int titleColor) |
Set the subtitle font color |
| setSubTitleStyle(String title, int titleSize, int titleColor) |
Set the subtitle resource, text size, text color |
| setLeftText(String leftText) |
Set the left text |
| setLeftTextSize(int leftTextSize) |
Set the size of the word left |
| setLeftTextColor(int leftTextColor) |
Set the left text color |
| setLeftStyle(String leftText, int leftTextSize, int leftTextColor) |
Set the left text, text size, text color |
| setRightText(String rightText) |
Set the right text |
| setRightTextSize(int rightTextSize) |
Set the right text size |
| setRightTextColor(int rightTextColor) |
Set the right text color |
| setLeftImage(int imageResId) |
Set the left image |
| setRightImage(int imageResId) |
Set the right image |
| setTitleClickListener(OnClickListener listener) |
Title Click to listen |
| setTitleClickListener(OnMultiTouchListener listener) |
Set the title Click / Double-click Event |
| setLeftClickListener(OnClickListener listener) |
On the left and buttons, click on the monitor |
| setRightTextClickListener(OnClickListener listener) |
Right side text Click to listen |
| setRightImageClickListener(OnClickListener listener) |
Right button Click to listen |
| setIsLeftBackView(boolean isLeftBackView) |
Set whether the left text and buttons are returned button |
| setIsHaveLine(boolean haveLine) |
Set whether there is a split line at the bottom of the title bar |
| setLeftBackViewVisible |
Set the left icon to display or hidden |
| setLeftTextViewVisible |
Set the left text display or hidden |
| setRightTextViewVisible |
Set the right side display or hidden |
| setRightImageViewVisible |
Set the right icon to display or hidden |
| setTitleVisible |
Set the title display or hidden |
| setSubTitleVisible |
Set the subtitle display or hidden |
| setTitleLayoutBackground |
Set the title bar background color |
## License
TitleLayout is released under the [Apache License Version 2.0](LICENSE).