iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >Android编程实现将ButtonBar放在屏幕底部的方法
  • 238
分享到

Android编程实现将ButtonBar放在屏幕底部的方法

方法Android 2022-06-06 11:06:54 238人浏览 独家记忆
摘要

本文实例讲述了Android编程实现将ButtonBar放在屏幕底部的方法。分享给大家供大家参考,具体如下: 前面一篇《Android编程实现将tab选项卡放在屏幕底部的方法》

本文实例讲述了Android编程实现将ButtonBar放在屏幕底部的方法。分享给大家供大家参考,具体如下:

前面一篇《Android编程实现将tab选项卡放在屏幕底部的方法》提到ButtonBar的方式写底部button,试了试,看起来外观貌似比Tab好看,不过恐怕没有Tab管理Activity方便吧,毕竟一 个Tab就是一个Activity,但是这样用Button的话,却并不如此,所以这样的涉及可能虽然好看点,但是管理起来却是相当麻烦。那么暂且把对 activity的管理放在一边,只看界面的设计吧。

要涉及这样的一个buttonbar,主要就是要用到style="@android:style/ButtonBar"这个风格。首先还是来看xml的设计,保存layout/bottombtn.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="Http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/textOut"
    android:padding="5px" android:layout_weight="1"/>
  <LinearLayout style="@android:style/ButtonBar"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button android:id="@+id/button_weather" android:text="@string/bottom_weather"
      android:layout_width="0dip" android:layout_height="wrap_content"
      android:layout_weight="1"/>
    <Button android:id="@+id/button_mail" android:text="@string/bottom_mail"
      android:layout_width="0dip" android:layout_height="wrap_content"
      android:layout_weight="1"/>
    <Button android:id="@+id/button_train" android:text="@string/bottom_train"
      android:layout_width="0dip" android:layout_height="wrap_content"
      android:layout_weight="1"/>
    <Button android:id="@+id/button_sites" android:text="@string/bottom_sites"
      android:layout_width="0dip" android:layout_height="wrap_content"
      android:layout_weight="1"/>
    <Button android:id="@+id/button_stock" android:text="@string/bottom_stock"
      android:layout_width="0dip" android:layout_height="wrap_content"
       android:layout_weight="1"/>
  </LinearLayout>
</LinearLayout>

然后就是关于这个的全部代码了:


package net.wangliping.popup;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class BottomBtn extends Activity {
  private static String LOG_TAG = "BottomBtn";
  private TextView tv;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bottombtn);
    tv = (TextView)findViewById(R.id.textOut);
    tv.setText("http://tools.wangliping.net");
  }
}

如此这般,就形成了下面的这个东西,虽然界面上看起来稍微美观一点,还是上面那句话:管理器Activity不一定很方便哦。

更多关于Android相关内容感兴趣的读者可查看本站专题:《Android开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结》

希望本文所述对大家Android程序设计有所帮助。

您可能感兴趣的文章:Android动态修改ToolBar的Menu菜单示例Android自定义谷歌风格ProgressBarAndroid ToolBar整合实例使用方法详解Android UI控件RatingBar实现自定义星星评分效果Android编程之ProgressBar圆形进度条颜色设置方法Android编程实现ActionBar的home图标动画切换效果Android判断NavigationBar是否显示的方法(获取屏幕真实的高度)Android编程实现将tab选项卡放在屏幕底部的方法Android6.0 固定屏幕功能实现方法及实例Android仿淘宝view滑动至屏幕顶部会一直停留在顶部的位置Android Animation实战之屏幕底部弹出PopupWindowandroid 选项卡(TabHost)如何放置在屏幕的底部


--结束END--

本文标题: Android编程实现将ButtonBar放在屏幕底部的方法

本文链接: https://www.lsjlt.com/news/28344.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作