全部产品

自定义导航栏(10.1.60)

更新时间:2020-06-11 15:20:17

如果有自定义 H5 容器标题栏的需求,参考下方示例代码实现:

10.1.60

H5TitleViewImpl.java

  1. package com.mpaas.demo.nebula;
  2. import android.app.Activity;
  3. import android.content.Context;
  4. import android.graphics.Bitmap;
  5. import android.graphics.Color;
  6. import android.graphics.drawable.ColorDrawable;
  7. import android.os.Bundle;
  8. import android.text.TextUtils;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.widget.ImageButton;
  13. import android.widget.LinearLayout;
  14. import android.widget.TextView;
  15. import com.alibaba.fastjson.JSONArray;
  16. import com.alibaba.fastjson.JSONObject;
  17. import com.alipay.mobile.h5container.api.H5Page;
  18. import com.alipay.mobile.h5container.api.H5Param;
  19. import com.alipay.mobile.h5container.api.H5Plugin;
  20. import com.alipay.mobile.nebula.util.H5Log;
  21. import com.alipay.mobile.nebula.util.H5StatusBarUtils;
  22. import com.alipay.mobile.nebula.util.H5Utils;
  23. import com.alipay.mobile.nebula.view.H5TitleBarFrameLayout;
  24. import com.alipay.mobile.nebula.view.H5TitleView;
  25. import com.alipay.mobile.nebula.view.IH5TinyPopMenu;
  26. import java.util.ArrayList;
  27. import java.util.List;
  28. /**
  29. * Created by omg on 2018/7/23.
  30. */
  31. public class H5TitleViewImpl implements H5TitleView, View.OnClickListener {
  32. private static final String TAG = "H5TitleViewImpl";
  33. private Context mContext;
  34. private H5TitleBarFrameLayout contentView;
  35. private String title;
  36. // 此处定义标题栏的基本控件
  37. private TextView mTitleView;
  38. private TextView mSubTitleView;
  39. private View mCloseButton;
  40. private View mBackButton;
  41. private View vDivider;
  42. private View hDivider;
  43. private View statusBarAdjustView;
  44. /**
  45. * ==== OptionMenu的各种View Start ====
  46. */
  47. // OptionMenu的Container
  48. public View h5NavOptions;
  49. public View h5NavOptions1;
  50. public List<View> h5NavOptionsList = new ArrayList<View>();
  51. // ---- OptionMenu 三种形态 Start ---- //
  52. // 1. OptionType.MENU(默认) -默认的 Option 按钮
  53. public TextView btMenu;
  54. public TextView btMenu1;
  55. public List<TextView> btMenuList = new ArrayList<TextView>();
  56. // 2. OptionType.ICON - 通过 setOptionMenu 手动设置的 icon
  57. public ImageButton btIcon;
  58. public ImageButton btIcon1;
  59. public List<ImageButton> btIconList = new ArrayList<ImageButton>();
  60. // 3. OptionType.TEXT - 文字
  61. public TextView btText;
  62. public TextView btText1;
  63. public List<TextView> btTextList = new ArrayList<TextView>();
  64. // ---- OptionMenu 三种形态 Over ---- //
  65. // Web 页面的实例接口类,可用于控制 web 行为
  66. private H5Page h5Page;
  67. private int visibleOptionNum = 0;
  68. private IH5TinyPopMenu h5TinyPopMenu;
  69. /**
  70. * H5 容器标题栏构造方法
  71. * 注意:标题栏布局 xml 文件必须以 H5TitleBarFrameLayout 作为根节点
  72. * @param context
  73. */
  74. public H5TitleViewImpl(Context context) {
  75. mContext = context;
  76. ViewGroup parent = null;
  77. if (context instanceof Activity) {
  78. parent = (ViewGroup) ((Activity) mContext).findViewById(android.R.id.content);
  79. }
  80. contentView = (H5TitleBarFrameLayout) LayoutInflater.from(context).inflate(R.layout.h5_navigation_bar, parent, false);
  81. contentView.getContentBgView().setColor(context.getResources().getColor(R.color.h5_default_titlebar_color));
  82. mTitleView = (TextView) contentView.findViewById(R.id.h5_tv_title);
  83. mTitleView.setOnClickListener(this);
  84. mSubTitleView = (TextView) contentView.findViewById(R.id.h5_tv_subtitle);
  85. mSubTitleView.setOnClickListener(this);
  86. mCloseButton = contentView.findViewById(R.id.h5_nav_close);
  87. mCloseButton.setOnClickListener(this);
  88. mBackButton = contentView.findViewById(R.id.h5_tv_nav_back);
  89. mBackButton.setOnClickListener(this);
  90. vDivider = contentView.findViewById(R.id.h5_v_divider);
  91. hDivider = contentView.findViewById(R.id.h5_h_divider_intitle);
  92. h5NavOptions = contentView.findViewById(R.id.h5_nav_options);
  93. h5NavOptions1 = contentView.findViewById(R.id.h5_nav_options1);
  94. statusBarAdjustView = contentView.findViewById(R.id.h5_status_bar_adjust_view);
  95. btIcon = (ImageButton) contentView.findViewById(R.id.h5_bt_image);
  96. btText = (TextView) contentView.findViewById(R.id.h5_bt_text);
  97. btMenu = (TextView) contentView.findViewById(R.id.h5_bt_options);
  98. btIcon1 = (ImageButton) contentView.findViewById(R.id.h5_bt_image1);
  99. btText1 = (TextView) contentView.findViewById(R.id.h5_bt_text1);
  100. btMenu1 = (TextView) contentView.findViewById(R.id.h5_bt_options1);
  101. //add view to list
  102. h5NavOptionsList.add(h5NavOptions);
  103. h5NavOptionsList.add(h5NavOptions1);
  104. btIconList.add(btIcon);
  105. btIconList.add(btIcon1);
  106. btTextList.add(btText);
  107. btTextList.add(btText1);
  108. btMenuList.add(btMenu);
  109. btMenuList.add(btMenu1);
  110. btText.setOnClickListener(this);
  111. btIcon.setOnClickListener(this);
  112. btText1.setOnClickListener(this);
  113. btIcon1.setOnClickListener(this);
  114. btMenu.setOnClickListener(this);
  115. btMenu1.setOnClickListener(this);
  116. }
  117. /**
  118. * 容器调用此方法获得主标题内容
  119. */
  120. @Override
  121. public String getTitle() {
  122. return title;
  123. }
  124. /**
  125. * 容器调用此方法设置主标题内容
  126. */
  127. @Override
  128. public void setTitle(String s) {
  129. title = s;
  130. mTitleView.setText(s);
  131. }
  132. /**
  133. * 容器调用此方法设置副标题内容
  134. */
  135. @Override
  136. public void setSubTitle(String s) {
  137. mSubTitleView.setVisibility(View.VISIBLE);
  138. mSubTitleView.setText(s);
  139. }
  140. /**
  141. * 暂时忽略,可不实现
  142. */
  143. @Override
  144. public void setImgTitle(Bitmap bitmap) {
  145. }
  146. /**
  147. * 暂时忽略,可不实现
  148. */
  149. @Override
  150. public void setImgTitle(Bitmap bitmap, String s) {
  151. }
  152. /**
  153. * 容器设置是否显示关闭按钮
  154. */
  155. @Override
  156. public void showCloseButton(boolean b) {
  157. mCloseButton.setVisibility(b ? View.VISIBLE : View.GONE);
  158. }
  159. /**
  160. * 容器获取标题栏 View
  161. */
  162. @Override
  163. public View getContentView() {
  164. return contentView;
  165. }
  166. /**
  167. * 容器获取标题栏背景用于设置背景色
  168. */
  169. @Override
  170. public ColorDrawable getContentBgView() {
  171. return contentView.getContentBgView();
  172. }
  173. /**
  174. * 容器获取主标题 View
  175. * 不可为空
  176. */
  177. @Override
  178. public TextView getMainTitleView() {
  179. return mTitleView;
  180. }
  181. /**
  182. * 容器获取副标题 View
  183. * 不可为空
  184. */
  185. @Override
  186. public TextView getSubTitleView() {
  187. return mSubTitleView;
  188. }
  189. /**
  190. * 设置是否展示返回按钮
  191. */
  192. @Override
  193. public void showBackButton(boolean b) {
  194. mBackButton.setVisibility(b ? View.VISIBLE : View.GONE);
  195. }
  196. /**
  197. * 设置是否显示右上角菜单项
  198. */
  199. @Override
  200. public void showOptionMenu(boolean isShow) {
  201. if (isShow) {
  202. switch (visibleOptionNum) {
  203. case 1:
  204. h5NavOptions.setVisibility(View.VISIBLE);
  205. break;
  206. case 2:
  207. h5NavOptions.setVisibility(View.VISIBLE);
  208. h5NavOptions1.setVisibility(View.VISIBLE);
  209. break;
  210. }
  211. } else {
  212. h5NavOptions.setVisibility(View.GONE);
  213. h5NavOptions1.setVisibility(View.GONE);
  214. }
  215. }
  216. /**
  217. * 设置右上角菜单项展示类型,可为图标、文字
  218. */
  219. @Override
  220. public void setOptionType(H5Param.OptionType optionType) {
  221. setOptionType(optionType, 0, true);
  222. }
  223. /**
  224. * 设置右上角菜单项展示类型,可为图标、文字
  225. * @param byIndex 是否只对某个菜单项设置展示类型
  226. */
  227. @Override
  228. public void setOptionType(H5Param.OptionType type, int num, boolean byIndex) {
  229. boolean icon = false;
  230. boolean text = false;
  231. boolean menu = false;
  232. if (type == H5Param.OptionType.ICON) {
  233. icon = true;
  234. } else if (type == H5Param.OptionType.TEXT) {
  235. text = true;
  236. } else if (type == H5Param.OptionType.MENU) {
  237. menu = true;
  238. }
  239. ctrlbtText(num, text ? View.VISIBLE : View.GONE, byIndex);
  240. ctrlbtIcon(num, icon ? View.VISIBLE : View.INVISIBLE, byIndex);
  241. ctrlbtMenu(num, menu ? View.VISIBLE : View.INVISIBLE, byIndex);
  242. }
  243. //view visible control
  244. private boolean isOutOfBound(int num, int length) {
  245. if (length == 0) {
  246. return true;
  247. }
  248. return length < num;
  249. }
  250. private void ctrlbtText(int num, int visible, boolean byIndex) {
  251. if (isOutOfBound(num, btTextList.size())) {
  252. return;
  253. }
  254. if (byIndex) {
  255. btTextList.get(num).setVisibility(visible);
  256. } else {
  257. for (int i = 0; i < num; i++) {
  258. btTextList.get(i).setVisibility(visible);
  259. }
  260. }
  261. }
  262. private void ctrlbtIcon(int num, int visible, boolean byIndex) {
  263. if (isOutOfBound(num, btIconList.size())) {
  264. return;
  265. }
  266. if (byIndex) {
  267. btIconList.get(num).setVisibility(visible);
  268. } else {
  269. for (int i = 0; i < num; i++) {
  270. btIconList.get(i).setVisibility(visible);
  271. }
  272. }
  273. }
  274. private void ctrlbtMenu(int num, int visible, boolean byIndex) {
  275. if (isOutOfBound(num, btMenuList.size())) {
  276. return;
  277. }
  278. if (byIndex) {
  279. btMenuList.get(num).setVisibility(visible);
  280. } else {
  281. for (int i = 0; i < num; i++) {
  282. btMenuList.get(i).setVisibility(visible);
  283. }
  284. }
  285. }
  286. /**
  287. * 设置是否在标题栏上显示加载状态,可自行选择实现方式
  288. */
  289. @Override
  290. public void showTitleLoading(boolean b) {
  291. }
  292. /**
  293. * 可忽略
  294. */
  295. @Override
  296. public void showTitleDisclaimer(boolean b) {
  297. }
  298. // 设置右上角按钮图标
  299. @Override
  300. public void setBtIcon(Bitmap btIcon, int index) {
  301. if (isOutOfBound(index, btIconList.size())) {
  302. return;
  303. }
  304. btIconList.get(index).setImageBitmap(btIcon);
  305. }
  306. @Override
  307. public void setH5Page(H5Page h5Page) {
  308. this.h5Page = h5Page;
  309. }
  310. /**
  311. * 根据 JS 传递过来的参数设置右上角菜单
  312. */
  313. @Override
  314. public void setOptionMenu(JSONObject params) {
  315. boolean reset = H5Utils.getBoolean(params, "reset", false);
  316. boolean override = H5Utils.getBoolean(params, "override", false);
  317. JSONArray menus = H5Utils.getJSONArray(params, "menus", null);
  318. if (reset) {
  319. h5NavOptions1.setVisibility(View.GONE);
  320. setOptionType(H5Param.OptionType.MENU, 0, true);
  321. visibleOptionNum = 1;
  322. return;
  323. }
  324. if (menus != null && !menus.isEmpty()) {
  325. visibleOptionNum = 0;
  326. if (override) {
  327. int menuSize = menus.size() > 2 ? 2 : menus.size();
  328. for (int i = 0; i < menuSize; i++) {
  329. // h5NavOptionsList.get(i).setVisibility(View.VISIBLE);
  330. JSONObject menusItem = menus.getJSONObject(i);
  331. setOptionMenuInternal(menusItem, i);
  332. visibleOptionNum++;
  333. }
  334. } else {
  335. visibleOptionNum = 2;
  336. // h5NavOptionsList.get(1).setVisibility(View.VISIBLE);
  337. JSONObject menusItem = menus.getJSONObject(0);
  338. setOptionMenuInternal(menusItem, 1);
  339. }
  340. } else {
  341. setOptionMenuInternal(params, 0);
  342. visibleOptionNum = 1;
  343. }
  344. }
  345. private void setOptionMenuInternal(JSONObject params, int index) {
  346. String title = H5Utils.getString(params, "title");
  347. String icon = H5Utils.getString(params, "icon");
  348. String icontype = H5Utils.getString(params, "icontype");
  349. String contentDesc = H5Utils.getString(params, "contentDesc");
  350. String colorText = H5Utils.getString(params, "color");
  351. // default white color
  352. int color = 0xFF108ee9;
  353. if (!TextUtils.isEmpty(colorText)) {
  354. try {
  355. color = Color.parseColor(colorText);
  356. } catch (Throwable ignore) {
  357. //can not find logutil
  358. }
  359. color = 0xFF000000 | color;
  360. btTextList.get(index).setTextColor(color);
  361. } else {
  362. int currentColor = mTitleView.getCurrentTextColor();
  363. currentColor = 0xFF000000 | currentColor;
  364. H5Log.d(TAG, "setOptionMenuInternal currentColor is " + currentColor);
  365. if (currentColor != 0xFF111111) {
  366. btText.setTextColor(0xFFFFFFFF);
  367. btText1.setTextColor(0xFFFFFFFF);
  368. } else {
  369. btText.setTextColor(0xFF108ee9);
  370. btText1.setTextColor(0xFF108ee9);
  371. }
  372. }
  373. if (!TextUtils.isEmpty(title)) {
  374. title = title.trim();
  375. btTextList.get(index).setText(title);
  376. setOptionType(H5Param.OptionType.TEXT, index, true);
  377. btTextList.get(index).setContentDescription(title);
  378. } else if (!TextUtils.isEmpty(icon) || !TextUtils.isEmpty(icontype)) {
  379. if (!TextUtils.isEmpty(contentDesc)) {
  380. btIconList.get(index).setContentDescription(contentDesc);
  381. }
  382. }
  383. }
  384. /**
  385. * 容器获取返回按钮和标题内容之间的分割线
  386. * 可返回空
  387. */
  388. @Override
  389. public View getDivider() {
  390. return vDivider;
  391. }
  392. /**
  393. * 容器获取标题栏和 Web 页面间的分割线
  394. * 不可为空
  395. */
  396. @Override
  397. public View getHdividerInTitle() {
  398. return hDivider;
  399. }
  400. /**
  401. * 容器获取下拉菜单弹出位置的锚点View
  402. */
  403. @Override
  404. public View getPopAnchor() {
  405. return btMenu;
  406. }
  407. /**
  408. * 容器重置标题栏背景色
  409. */
  410. @Override
  411. public void resetTitleColor(int color) {
  412. }
  413. /**
  414. * 暂时忽略
  415. */
  416. @Override
  417. public void switchToWhiteTheme() {
  418. }
  419. /**
  420. * 暂时忽略
  421. */
  422. @Override
  423. public void switchToBlueTheme() {
  424. }
  425. /**
  426. * 容器页面销毁时触发,此处可释放被引用的 View
  427. */
  428. @Override
  429. public void releaseViewList() {
  430. if (h5NavOptionsList != null) {
  431. h5NavOptionsList.clear();
  432. }
  433. if (btIconList != null) {
  434. btIconList.clear();
  435. }
  436. if (btTextList != null) {
  437. btTextList.clear();
  438. }
  439. if (btMenuList != null) {
  440. btMenuList.clear();
  441. }
  442. }
  443. /**
  444. * 容器设置沉浸式标题栏颜色
  445. */
  446. @Override
  447. public void openTranslucentStatusBarSupport(int color) {
  448. if (H5StatusBarUtils.isSupport()) {
  449. int statusBarHeight = H5StatusBarUtils.getStatusBarHeight(mContext);
  450. if (statusBarHeight == 0) { //保护,万一有 rom 没办法拿到状态栏高度的话,则在这里不生效。
  451. return;
  452. }
  453. LinearLayout.LayoutParams layoutParams =
  454. (LinearLayout.LayoutParams) statusBarAdjustView.getLayoutParams();
  455. layoutParams.height = statusBarHeight;
  456. statusBarAdjustView.setLayoutParams(layoutParams);
  457. statusBarAdjustView.setVisibility(View.VISIBLE);
  458. try {
  459. H5StatusBarUtils.setTransparentColor((Activity) mContext, color);
  460. } catch (Exception e) {
  461. H5Log.e(TAG, e);
  462. }
  463. }
  464. }
  465. /**
  466. * 暂时忽略
  467. */
  468. @Override
  469. public void switchToTitleBar() {
  470. }
  471. /**
  472. * 暂时忽略
  473. */
  474. @Override
  475. public View setTitleBarSearch(Bundle bundle) {
  476. return null;
  477. }
  478. /**
  479. * 暂时忽略
  480. */
  481. @Override
  482. public void setBackCloseBtnImage(String s) {
  483. }
  484. /**
  485. * 设置标题栏字体颜色
  486. */
  487. @Override
  488. public void setTitleTxtColor(int i) {
  489. mTitleView.setTextColor(i);
  490. mSubTitleView.setTextColor(i);
  491. }
  492. /**
  493. * 容器获取右上角菜单 View, 必须是ViewGroup及子类
  494. */
  495. @Override
  496. public View getOptionMenuContainer() {
  497. return h5NavOptions;
  498. }
  499. /**
  500. * 容器根据位置获取右上角菜单 View,必须是ViewGroup及子类
  501. */
  502. @Override
  503. public View getOptionMenuContainer(int index) {
  504. switch (index) {
  505. case 0:
  506. return h5NavOptions;
  507. case 1:
  508. return h5NavOptions1;
  509. default:
  510. return getOptionMenuContainer();
  511. }
  512. }
  513. /**
  514. * 暂时忽略
  515. */
  516. @Override
  517. public void setIH5TinyPopMenu(IH5TinyPopMenu tinyPopMenu) {
  518. this.h5TinyPopMenu = tinyPopMenu;
  519. }
  520. /**
  521. * 暂时忽略
  522. */
  523. @Override
  524. public IH5TinyPopMenu getH5TinyPopMenu() {
  525. return null;
  526. }
  527. /**
  528. * 暂时忽略
  529. */
  530. @Override
  531. public void setTitleView(View view) {
  532. }
  533. /**
  534. * 暂时忽略
  535. */
  536. @Override
  537. public void initTitleSegControl(JSONObject jsonObject) {
  538. }
  539. /**
  540. * 暂时忽略
  541. */
  542. @Override
  543. public void enableTitleSegControl(boolean b) {
  544. }
  545. /**
  546. * 暂时忽略
  547. */
  548. @Override
  549. public void enableBackButtonBackground(boolean b) {
  550. }
  551. /**
  552. * 处理标题栏上不同控件的点击事件
  553. * 如果 JS 需要收到事件,需按照该代码中呈现的方式发送事件给 JS
  554. * 比如点击返回按钮,则发送 H5Plugin.CommonEvents.H5_TOOLBAR_BACK 事件
  555. */
  556. @Override
  557. public void onClick(View view) {
  558. if (h5Page == null) {
  559. return ;
  560. }
  561. String eventName = null;
  562. JSONObject data = null;
  563. if (view == mBackButton) {
  564. eventName = H5Plugin.CommonEvents.H5_TOOLBAR_BACK; // 发送后退事件
  565. } else if (view == mCloseButton) {
  566. eventName = H5Plugin.CommonEvents.H5_TOOLBAR_CLOSE; // 发送关闭页面事件
  567. }else if (view.equals(btIcon) || view.equals(btText)) {
  568. eventName = H5Plugin.CommonEvents.H5_TITLEBAR_OPTIONS;
  569. data = new JSONObject();
  570. data.put("index", 0);
  571. } else if (view.equals(btIcon1) || view.equals(btText1)) {
  572. eventName = H5Plugin.CommonEvents.H5_TITLEBAR_OPTIONS;
  573. data = new JSONObject();
  574. data.put("index", 1);
  575. } else if (view.equals(btMenu) || view.equals(btMenu1)) {
  576. eventName = H5Plugin.CommonEvents.H5_TITLEBAR_OPTIONS;
  577. data = new JSONObject();
  578. data.put("fromMenu", true);
  579. data.put("index", view.equals(btMenu) ? 0 : 1);
  580. } else if (view.equals(mTitleView)) {
  581. eventName = H5Plugin.CommonEvents.H5_TITLEBAR_TITLE;
  582. } else if (view.equals(mSubTitleView)) {
  583. eventName = H5Plugin.CommonEvents.H5_TITLEBAR_SUBTITLE;
  584. }
  585. if (!TextUtils.isEmpty(eventName)) {
  586. h5Page.sendEvent(eventName, data);
  587. }
  588. }
  589. }

h5_navigation_bar.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <com.alipay.mobile.nebula.view.H5TitleBarFrameLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:id="@+id/h5_title_bar"
  6. android:layout_width="match_parent"
  7. android:layout_height="wrap_content"
  8. android:background="@android:color/transparent">
  9. <LinearLayout
  10. android:id="@+id/h5_rl_title_bar"
  11. android:layout_width="match_parent"
  12. android:layout_height="wrap_content"
  13. android:background="@android:color/transparent"
  14. android:orientation="vertical">
  15. <View
  16. android:id="@+id/h5_status_bar_adjust_view"
  17. android:layout_width="match_parent"
  18. android:layout_height="wrap_content"
  19. android:visibility="gone"/>
  20. <RelativeLayout
  21. android:id="@+id/h5_title_bar_layout"
  22. android:layout_width="match_parent"
  23. android:layout_height="48dp">
  24. <ImageButton
  25. android:id="@+id/h5_tv_nav_back"
  26. android:layout_width="48dp"
  27. android:layout_height="match_parent"
  28. android:layout_alignParentLeft="true"
  29. android:layout_centerVertical="true"
  30. android:background="@android:color/transparent"
  31. android:scaleType="centerInside"
  32. android:padding="12dp"
  33. android:src="@drawable/back"/>
  34. <ImageButton
  35. android:id="@+id/h5_nav_close"
  36. android:layout_width="48dp"
  37. android:layout_height="match_parent"
  38. android:layout_centerVertical="true"
  39. android:padding="12dp"
  40. android:layout_marginLeft="-6dp"
  41. android:layout_toRightOf="@+id/h5_tv_nav_back"
  42. android:background="@android:color/transparent"
  43. android:clickable="true"
  44. android:scaleType="centerInside"
  45. android:src="@drawable/close"/>
  46. <View
  47. android:id="@+id/h5_v_divider"
  48. android:layout_width="0.7dp"
  49. android:layout_height="24dp"
  50. android:layout_centerVertical="true"
  51. android:layout_gravity="center"
  52. android:layout_marginRight="12dp"
  53. android:layout_toRightOf="@+id/h5_nav_close"
  54. tools:ignore="ContentDescription"/>
  55. <RelativeLayout
  56. android:id="@+id/h5_rl_title"
  57. android:layout_width="match_parent"
  58. android:layout_height="wrap_content"
  59. android:layout_centerVertical="true"
  60. android:gravity="center">
  61. <LinearLayout
  62. android:id="@+id/h5_ll_title"
  63. android:layout_width="wrap_content"
  64. android:layout_height="match_parent"
  65. android:gravity="center"
  66. android:orientation="vertical">
  67. <FrameLayout
  68. android:layout_width="wrap_content"
  69. android:layout_height="wrap_content">
  70. <TextView
  71. android:id="@+id/h5_tv_title"
  72. android:layout_width="wrap_content"
  73. android:layout_height="wrap_content"
  74. android:ellipsize="end"
  75. android:singleLine="true"
  76. android:textColor="@android:color/white"
  77. android:textSize="16dp" />
  78. <ImageView
  79. android:id="@+id/h5_tv_title_img"
  80. android:layout_width="wrap_content"
  81. android:layout_height="36dp"
  82. android:scaleType="centerInside"
  83. android:visibility="gone"/>
  84. </FrameLayout>
  85. <TextView
  86. android:id="@+id/h5_tv_subtitle"
  87. android:layout_width="wrap_content"
  88. android:layout_height="wrap_content"
  89. android:singleLine="true"
  90. android:textColor="@android:color/white"
  91. android:textSize="12dp"
  92. android:visibility="gone"
  93. tools:visibility="visible" />
  94. </LinearLayout>
  95. </RelativeLayout>
  96. <!-- optionmenu0-->
  97. <FrameLayout
  98. android:id="@+id/h5_nav_options"
  99. android:layout_width="wrap_content"
  100. android:layout_height="fill_parent"
  101. android:layout_alignParentRight="true"
  102. android:layout_centerVertical="true"
  103. android:layout_marginLeft="6dp">
  104. <ImageButton
  105. android:id="@+id/h5_bt_image"
  106. android:layout_width="32dp"
  107. android:layout_height="32dp"
  108. android:layout_gravity="center|right"
  109. android:layout_marginRight="12dp"
  110. android:background="@android:color/transparent"
  111. android:padding="4dp"
  112. android:scaleType="fitCenter"
  113. android:visibility="gone"/>
  114. <TextView
  115. android:id="@+id/h5_bt_text"
  116. android:layout_width="wrap_content"
  117. android:layout_height="wrap_content"
  118. android:layout_gravity="center|right"
  119. android:layout_marginRight="12dp"
  120. android:background="@null"
  121. android:ellipsize="end"
  122. android:maxLength="8"
  123. android:singleLine="true"
  124. android:textColor="#ffffff"
  125. android:textSize="16dp"/>
  126. <TextView
  127. android:id="@+id/h5_bt_options"
  128. android:layout_width="48dp"
  129. android:layout_height="match_parent"
  130. android:background="@null"
  131. android:gravity="center"
  132. android:textSize="23dp"
  133. android:visibility="gone"
  134. tools:visibility="gone" />
  135. </FrameLayout>
  136. <!-- optionmenu1-->
  137. <FrameLayout
  138. android:id="@+id/h5_nav_options1"
  139. android:layout_width="wrap_content"
  140. android:layout_height="fill_parent"
  141. android:layout_centerVertical="true"
  142. android:layout_marginLeft="6dp"
  143. android:layout_toLeftOf="@id/h5_nav_options"
  144. android:visibility="gone"
  145. tools:visibility="visible">
  146. <ImageButton
  147. android:id="@+id/h5_bt_image1"
  148. android:layout_width="32dp"
  149. android:layout_height="32dp"
  150. android:layout_gravity="center|right"
  151. android:layout_marginRight="12dp"
  152. android:background="@android:color/transparent"
  153. android:padding="4dp"
  154. android:scaleType="fitCenter"
  155. android:visibility="gone"/>
  156. <TextView
  157. android:id="@+id/h5_bt_text1"
  158. android:layout_width="wrap_content"
  159. android:layout_height="wrap_content"
  160. android:layout_gravity="center|right"
  161. android:layout_marginRight="12dp"
  162. android:background="@null"
  163. android:ellipsize="end"
  164. android:maxLength="8"
  165. android:singleLine="true"
  166. android:textColor="#108ee9"
  167. android:textSize="16dp"/>
  168. </FrameLayout>
  169. </RelativeLayout>
  170. <View
  171. android:id="@+id/h5_h_divider_intitle"
  172. android:layout_width="match_parent"
  173. android:layout_height="1px"
  174. android:background="@android:color/white"
  175. android:visibility="gone"/>
  176. </LinearLayout>
  177. </com.alipay.mobile.nebula.view.H5TitleBarFrameLayout>