涉及公司内部程序,部分地方进行模糊处理。

公司Android程序的一个子程序UI要进行改版,最初的UI添加按钮是在内容区,而且TabHost空间是正常的标题平均分布。如下图(其实这是改版的第一版,没有了添加按钮,但是还是标题还是平均分布。)

但是,后来改版后,“添加”按钮变成了这样:

这个界面上,首先,TabHost集中在左侧,然后“加号”按钮变到了右侧,而且第一和第二个Tab有按钮,第三个“设置”Tab没有加号。

由于是在原基础上改版,源程序也是原来的同事写的,所以就尽量小的改动源程序。所以在原来的自定义TabHost的基础上进行更改,如下:

[code lang="xml"]
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_background"
android:orientation="horizontal" >

<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TabWidget
android:layout_marginTop="0dp"
android:layout_marginLeft="0dp"
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="68dip" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="7">
</FrameLayout>
</LinearLayout>
<!--在这里加一个Button -->
<Button
android:id="@+id/btn_add"
android:layout_width="40dip"
android:layout_height="40dip"
android:background="@drawable/jiahao"
android:layout_marginLeft="700dip"
android:layout_marginTop="15dip"/>
</TabHost>
</LinearLayout>
[/code]

在主Activity中更改onCtreate:

[java]
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
mTabHost = getTabHost();
initbacklist(); //加载黑名单;
initwhitelist(); //加载白名单;
firewallset(); //加载设置界面
//设置没个标题的宽度,这样Tab标题就集中在了左侧
TabWidget tabget0 = mTabHost.getTabWidget();
tabget0.getChildAt(0).getLayoutParams().width = 178;
tabget0.getChildAt(1).getLayoutParams().width = 178;
tabget0.getChildAt(2).getLayoutParams().width = 178;
}
[/java]

这样就让Tab的标题集中在左边,右侧添加了一个公共的按钮。下一次介绍如何使用公共的按钮。

Android TabHost控件 右侧留空并增加按钮的更多相关文章

  1. android TabHost控件

    (一)TabHost控件,默认是在顶部显示的 TabHost是盛放Tab按钮和Tab内容的首要容器, TabWidget(tabs标签)用于选择页面,是指一组包含文本或图标的 ,FrameLayout ...

  2. Android 开源控件与常用开发框架开发工具类

    Android的加载动画AVLoadingIndicatorView 项目地址: https://github.com/81813780/AVLoadingIndicatorView 首先,在 bui ...

  3. 一个Demo让你掌握Android所有控件

    原文:一个Demo让你掌握Android所有控件 本文是转载收藏,侵删,出处:"安卓巴士"      下面给出实现各个组件的源代码: 1.下拉框实现--Spinner packag ...

  4. Android之控件使用

    Android系统为我们提供了大量的控件,例如:开关控件.单选按钮.多选按钮.单选菜单等等,那么这些控件如何使用呢?本篇我将带领大家一道学习一下如何使用这些控件.所谓无图无真相,先让大家看一下效果图: ...

  5. Android常用控件及对应Robotium API

    最近发现Android控件不熟悉,看Robotium的API都费劲. 常用Android控件: 控件类型 描述 相关类 Button 按钮,可以被用户按下或点击,以执行⼀个动作 Button Text ...

  6. android 基础控件(EditView、SeekBar等)的属性及使用方法

        android提供了大量的UI控件,本文将介绍TextView.ImageView.Button.EditView.ProgressBar.SeekBar.ScrollView.WebView ...

  7. Android基本控件之Menus

    在我们的手机中有很多样式的菜单,比如:我们的短信界面,每条短信,我们长按都会出现一个菜单,还有很多的种类.那么现在,我们就来详细的讨论一下安卓中的菜单 Android的控件中就有这么一个,叫做Menu ...

  8. Android:控件布局(相对布局)RelativeLayout

    RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列. 相对布局常用属性: 子类控件相对子类控件:值是另外一个控件的id android:layout_above-- ...

  9. Android:控件布局(线性布局)LinearLayout

    LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...

随机推荐

  1. 使用CMake,且在GCC编译时指定相对源代码路径选项BUG的问题

    CMake的build.make,每次都是cd xxx目录,然后再编译 而编译时,GCC会取当前路径保存进调试信息的DT_AT_comp_dir,GCC的编译器选项-fdebug-prefix-map ...

  2. Codeforces 1099 D. Sum in the tree-构造最小点权和有根树 贪心+DFS(Codeforces Round #530 (Div. 2))

    D. Sum in the tree time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. 洛谷 P3919 【模板】可持久化数组(可持久化线段树/平衡树)-可持久化线段树(单点更新,单点查询)

    P3919 [模板]可持久化数组(可持久化线段树/平衡树) 题目背景 UPDATE : 最后一个点时间空间已经放大 标题即题意 有了可持久化数组,便可以实现很多衍生的可持久化功能(例如:可持久化并查集 ...

  4. ZOJ 3495 Lego Bricks

    计算几何,暴力. 题目中有一句话:$The$ $mass$ $of$ $each$ $brick$ $is$ $equally$ $distributed$ $and$ $it$ $will$ $be ...

  5. Git的入门级玩法

    作为一个还没有实际开发经验的程序员,对于版本控制多少有些陌生,我通常的做法就是项目名后面加数字标记版本,然后备注一个文档说明更新.据个人了解svn用的比较多,我也学习了一点,无非是本地下载一个服务器端 ...

  6. Flask实战第59天:首页帖子布局完成

    编辑front_index.html <div id="carousel-example-generic" class="carousel slide index- ...

  7. HDU5742 It's All In The Mind 数学思维题

    Problem Description Professor Zhang has a number sequence a1,a2,...,an. However, the sequence is not ...

  8. BZOJ 1202 [HNOI2005]狡猾的商人(并查集)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1202 [题目大意] 给出一些区间和的数值,问是否存在矛盾 [题解] 用并查集维护前缀和 ...

  9. 【递归】【线段树】【堆】AtCoder Regular Contest 080 E - Young Maids

    给你一个1~n的排列p,n是偶数,每次从中任选一对相邻的数出来,插到排列q的开头,如此循环,问你所能得到的字典序最小的排列q. 我们先确定q开头的两个数q1,q2,q1一定是p的奇数位的最小的数,而q ...

  10. 【树形dp】Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) B. Bear and Tree Jumps

    我们要统计的答案是sigma([L/K]),L为路径的长度,中括号表示上取整. [L/K]化简一下就是(L+f(L,K))/K,f(L,K)表示长度为L的路径要想达到K的整数倍,还要加上多少. 于是, ...