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>
效果例如以下图:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGlhbmdjYWl5dW4yMDEz/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
因为本人是刚開始学习的人,用这样的方法的时候没想到绑定监听器的办法,希望路过的大神指点一二。
方法二:
<Buttton
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:textSize="20sp"
android:text="呼叫丫头
(联通号)"/>
这样的方法是用“ ”这个符号实现一个button显示两行文本,这样就能够为这个button绑定监听器
可是在用的时候,假设符号两端都是用的“@string/...”,就会报错
瑾此一记。希望对你实用
android应用开发 button显示两行文本的更多相关文章
- Android应用开发学习之相对布局
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 相对布局RelativeLayout是指按照组件之间的相对位置进行布局,如一个组件在另一个组件的左边.右边.上边或下 ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包含图像的文本信息),并简要说明实现方法. 答案:Android SDK支持如下显示富文本信息的方式. 1.使用Tex ...
- Android应用开发-小巫CSDN博客client之显示博文具体内容
Android应用开发-小巫CSDN博客客户端之显示博文具体内容 上篇博文给大家介绍的是怎样嵌入有米广告而且获取收益,本篇博客打算讲讲关于怎样在一个ListView里显示博文的具体信息.这个可能是童鞋 ...
- Android APP开发入门教程-Button
代码编写 做好准备工作后,终于可以开始写我们的hello android了,在开始编写代码之前,我们先了解几个文件: res/layout/main.xml App主窗体布局文件,你的应用长什么样都在 ...
- Android控件_TextView(显示文本框控件)
一.TextView控件的常用属性 1.android:id——控件的id 2.android:layout_width——设置控件的宽度 wrap_content(包裹实际文本内容) fill ...
- 【转】 Android ListView与Button的显示----不错不错
原文网址:http://blog.csdn.net/zy987654zy/article/details/39225819 在开发中有时候会碰见一些很简单的问题,但是当初没想通的时候 死都搞不定. 我 ...
- Android应用开发基础篇(1)-----Button
Android应用开发基础篇(1)-----Button 一.概述 Button,顾名思义就是按钮的意思,它主要的功能是响应用户按下按钮时的动作. 二.应用 新建一个工程, ...
- android的开发 华为手机上不显示menu键
android的开发,华为手机上不显示menu键解决办法: 在AndroidManifest.xml中讲targetSdkVersion改为9. <uses-sdk android:minSdk ...
- 我的Android进阶之旅------> Android为TextView组件中显示的文本添加背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
随机推荐
- Microsoft SQL Server Version List(SQL Server 版本)
原帖地址 What version of SQL Server do I have? This unofficial build chart lists all of the known Servic ...
- 关于python中数组的问题,序列格式转换
https://blog.csdn.net/sinat_34474705/article/details/74458605?utm_source=blogxgwz1 https://www.cnblo ...
- USB串行端口
USB-SERIAL CH341A(COM22)USB串行端口
- ajax的get请求与编码
window.onload = function(){ document.getElementById('username').onblur = function(){ var name = docu ...
- Costura.Fody
使用Costura.Fody将源DLL合并到目标EXE 本文为原创文章,如转载,请在网页明显位置标明原文名称.作者及网址,谢谢! 一.本文主要是使用Costura.Fody工具将源DLL合并到目标EX ...
- Altium Designer线如何跟着原件走
- 【Codeforces Round #301 (Div. 2) D】 Bad Luck Island
[链接] 我是链接,点我呀:) [题意] 剪刀.石头.布各有r,s,p个生活在同一个村子里. 它们两两之间相遇的几率都相同(相遇后就会按照划拳的规则判断输赢,输的人就死掉了). 问你最后只剩下剪刀,只 ...
- [D3] Create Chart Axes with D3 v4
Most charts aren’t complete without axes to provide context and labeling for the graphical elements ...
- Oracle批量插入在C#中的应用
public void SetUserReportResult(int[] reportId, bool isReceive, string result) { if (reportId == nul ...
- 对Linux下常用头文件总结
asm.current.h 定义全局项current ,其指向结构体struct task_struct linux/sched.h 定义结构体task_struct ,只要包含此头文件 ...