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

 更新时间:2017年03月01日 10:47:17   作者:aloxc  
这篇文章主要介绍了Android编程实现将ButtonBar放在屏幕底部的方法,涉及Android界面设计与文本操作相关技巧,需要的朋友可以参考下

本文实例讲述了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仿京东首页轮播文字效果

    Android仿京东首页轮播文字效果

    这篇文章主要介绍了Android仿京东首页轮播文字效果,又名垂直跑马灯,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-10-10
  • Android Application的使用全面解析

    Android Application的使用全面解析

    这篇文章主要为大家介绍了Android Application的使用全面解析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-12-12
  • Android实现计步器功能

    Android实现计步器功能

    这篇文章主要为大家详细介绍了Android实现计步器功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-03-03
  • 浅谈Android View滑动冲突的解决方法

    浅谈Android View滑动冲突的解决方法

    本篇文章主要介绍了浅谈Android View滑动冲突的解决方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-02-02
  • Android自定义View中attrs.xml的实例详解

    Android自定义View中attrs.xml的实例详解

    这篇文章主要介绍了Android自定义View中attrs.xml的实例详解的相关资料,在自定义View首先对attrs.xml进行布局的实现及属性的应用,需要的朋友可以参考下
    2017-07-07
  • Android Studio 利用Splash制作APP启动界面的方法

    Android Studio 利用Splash制作APP启动界面的方法

    这篇文章主要介绍了Android Studio 利用Splash制作APP启动界面,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-05-05
  • Android漂浮背景效果的制作方法

    Android漂浮背景效果的制作方法

    这篇文章主要为大家详细介绍了Android漂浮背景效果的制作代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-02-02
  • Android开发中Flutter组件实用技巧

    Android开发中Flutter组件实用技巧

    这篇文章主要为大家介绍了Android开发中Flutter组件实用技巧,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-05-05
  • Android快速实现一个财务APP程序详解

    Android快速实现一个财务APP程序详解

    这篇文章主要介绍了Android实现的财务APP程序,结合前后端共功能完善,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-07-07
  • Android下拉列表框Spinner使用方法详解

    Android下拉列表框Spinner使用方法详解

    这篇文章主要为大家详细介绍了Android下拉列表框Spinner的基本使用,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-06-06

最新评论