Android View设置:VerticalTabLayout内容/Tab 居中对齐

'q.rorbin:VerticalTabLayout:1.2.5'

问题:优化VerticalTabLayout布局显示

结果:

处理流程:导入VerticalTabLayout Mudule到项目中或者复制模块代码,方便自己修改维护

1、找到QTabView,修改单个TabView布局,在此完成

2、设置图片+文字居中需要将LayoutParams中width,height都设置为LayoutParams.WRAP_CONTENT ,修改设置后params.gravity = Gravity.CENTER设置才有效

3、在initTitleView方法中,注释掉setGravity设置

4、refreshDrawablePadding设置图片和文字的距离

5、我的需求到此就完成啦,其他的各位大佬自己再研究一下,布局微调基本都在这个类里

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以按照以下方式创建一个名为 `midellBox` 的 Tabbar 底部导航栏组件,并在快速开单页面中正确引用 `tabbarList` : ```vue <template> <div> <router-link v-for="tab in tabbarList" :key="tab.id" :to="tab.path" class="tabbar-item"> <img :src="tab.icon" :class="{ active: currentPath === tab.path }" alt=""> <span :class="{ active: currentPath === tab.path }">{{ tab.text }}</span> </router-link> </div> </template> <script> export default { data() { return { tabbarList: [ { id: 0, path: 'pages/tab/order/index', icon: 'static/orderDefault.png', selectIcon: 'static/orderPress.png', text: '订单', centerItem: false }, { id: 1, path: 'pages/tab/quckBilling/quickBilling.vue', icon: 'static/userDefault.png', selectIcon: 'static/userPress.png', text: '快速开单', centerItem: true }, { id: 2, path: 'pages/tab/mine/mine', icon: 'static/userDefault.png', selectIcon: 'static/userPress.png', text: '我的', centerItem: false } ], currentPath: '' }; }, created() { this.currentPath = this.$route.path; } }; </script> <style> .tabbar { display: flex; justify-content: space-around; align-items: center; background-color: #f5f5f5; height: 60px; } .tabbar-item { display: flex; flex-direction: column; align-items: center; text-align: center; text-decoration: none; color: #999999; } .tabbar-item img { width: 24px; height: 24px; } .tabbar-item span { font-size: 12px; } .tabbar-item .active { color: #007aff; } </style> ``` 然后,在你的快速开单页面中引入 `midellBox` 组件,以正确使用 `tabbarList`: ```vue <template> <view> 快速开单 <midellBox></midellBox> </view> </template> <script> import midellBox from '@/components/modell-box/modell-box.vue'; export default { components: { midellBox } }; </script> <style lang="scss"> </style> ``` 这样,你就可以在快速开单页面中正确引用 `tabbarList` 并使用 `midellBox` 组件。请根据实际项目路径进行相应的调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值