zoukankan      html  css  js  c++  java
  • android应用开发 button显示两行文本

    自己写了个电话拨号器的程序给男朋友玩,用来专门打我的手机号,为了把界面做的好看一点,须要用到显示两行文本的button。在网上搜罗了两种方法,记录在以下。跟大家一起分享一下,希望能帮到须要的人。

    方法一:

    <LinearLayout 

          android:id="@+id/container" 

          android:layout_width="wrap_content" 

          android:layout_height="wrap_content" 

          tools:context="com.example.test.MainActivity"

          tools:ignore="MergeRootFrame" 

          android:clickable="true" 

          android:focusable="true" 

          android:orientation="vertical" 

          android:background="@android:drawable/btn_default">

          <TextView 

                  android:text="Hello" 

                  android:layout_width="wrap_content" 

                  android:gravity="center_horizontal"

                  android:layout_height="wrap_content" 

                  android:layout_weight="1"/>

         <TextView 

                  android:text="android" 

                  android:layout_width="wrap_content" 

                  android:layout_height="wrap_content" 

                  android:layout_gravity="center_horizontal" 

                  android:layout_weight="1"/>

    </LinearLayout>

    效果例如以下图:


    因为本人是刚開始学习的人,用这样的方法的时候没想到绑定监听器的办法,希望路过的大神指点一二。

    方法二:

    <Buttton

            android:id="@+id/button1"

            android:layout_width="wrap_content" 

            android:layout_height="wrap_content" 

            android:textColor="#FF0000"

            android:textSize="20sp"

            android:text="呼叫丫头 &#10; (联通号)"/>

    这样的方法是用“&#10;”这个符号实现一个button显示两行文本,这样就能够为这个button绑定监听器

    可是在用的时候,假设符号两端都是用的“@string/...”,就会报错

    瑾此一记。希望对你实用



  • 相关阅读:
    一、汇编基础知识
    PHP RabbitMQ消息队列演示代码
    PHP CentOS下安装PHP及部署ThinkPHP
    MySQL CentOS下安装MySQL
    ThinkPHP 对接支付宝支付接口
    ThinkPHP 获取当前页面完整的URL地址
    前端 Validform.js属性,用法及Ajax提交简介
    PHP 配置Xdebug调试工具
    ThinkPHP 原生分页功能改进,更好用更美观
    ThinkPHP 使用第三方phpmailer库发送邮件
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/7258410.html
Copyright © 2011-2022 走看看