⑴ android 如何实现竖排文字显示
在android.graphics.Canvas类中有个沿路径画字的方法
void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)
Draw the text, with origin at (x,y), using the specified paint, along the specified path.
Test.java代码://需要在layout中定义Test,且设置背景,在java代码中设置test Text
public class Test extends View {
private Paint paint;
private Path path;
private Matrix matrix;
private int width = -1;
private int height = -1;
private float left = 3;
private float top = 18;
private String title = "";
BitmapDrawable drawable = (BitmapDrawable) getBackground();
public Test(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint();
paint.setColor(Color.WHITE);//定义字体颜色
paint.setTextSize(14);//定义字体大小
path = new Path();
path.lineTo(0,500);//定义字符路径
matrix = new Matrix();
Log.v("onMeasure", "2");
}
@Override
protected void onDraw(Canvas canvas) {
//画背景
Bitmap b = Bitmap.createBitmap(drawable.getBitmap(),0,0,width,height);
canvas.drawBitmap(b, matrix, paint);
//画字
showText(canvas, title);
}
private void showText(Canvas canvas, String text){
float w;
final int len = text.length();
float py = 0 + top;
for(int i=0; i<len; i ++){
char c = text.charAt(i);
w = paint.measureText(text, i, i+1);//获取字符宽度
StringBuffer b = new StringBuffer();
b.append(c);
if(py > 81){//定义字的范围
return;
}
if(isChinese(c)){
py += w;
if(py > 81){
return;
}
canvas.drawText(b.toString(), left, py, paint); //中文处理方法
}else {
canvas.drawTextOnPath(b.toString(), path, py, -left-2, paint);//其他文字处理方法
py += w;
}
}
}
public void setText(String title){
this.title = title;
}
public String getText(){
return title;
}
private boolean isChinese(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
return true;
}
return false;
}
//重写View大小方法,使view大小为背景图片大小
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (null != getBackground()) {
int h = drawable.getIntrinsicHeight();
int w = drawable.getIntrinsicWidth();
Log.v("onMeasure", "null != getBackground() h:" + h + " w:" + w);
width = w;
height = h;
setMeasuredDimension(w, h);
} else {
width = widthMeasureSpec;
height = heightMeasureSpec;
super.measure(widthMeasureSpec, heightMeasureSpec);
}
}
}
在Android中,若要通过程序改变屏幕显示的方向,必须要覆盖setRequestedOrientation()方法,而若要取得目前的屏幕方向,则需要访问getRequestedOrientation()方法。本范例为求简要示范更改做法,设计了一个按钮,当单击按钮的同时,判断当下的屏幕方向,例如竖排(PORTRAIT),则将其更改为横排(LANDSCAPE);若为横排(LANDSCAPE),则将其更改为竖排(PORTRAIT)
⑵ 安卓有什么软件可以在悬浮窗上显示文字或者图片吗
是类似于LED字幕滚动的软件吗?
http://as..com/a/item?docid=250876&pre=web_am_rel&f=web_alad_4%40next
可以网络“字幕滚动”或者:“安卓LED字幕”什么的
⑶ 安卓手机玩一些日本游戏时有些字显示框框需要什么字体才能让他显示中文
你肯定装了第三方字体,你装的第三方字体不完整,你可以将备份的原系统自带字体换过来,或者去新下载新的字体包,去论坛下吧 我这有华康少女的完整包,12M多
希望能帮到你
⑷ Android 如何实现竖排文字显示
package com.coolsoft.attributionreject.tools;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;
public class VerticalTextView extends LinearLayout{
public VerticalTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(VERTICAL);
this.context=context;
}
private String text;
private Context context;
private int color;
private int size=15;
public VerticalTextView(Context context) {
super(context);
setOrientation(VERTICAL);
this.context=context;
}
public void setText(String text)
{
this.text=text;
addText();
}
private void addText()
{
removeAllViews();
if(text!=null)
{
char[] chara=text.toCharArray();
for(int i=0;i<chara.length;i++)
{
System.out.println("什么情况------"+text);
TextView oneText=new TextView(context);
oneText.setTextColor(color);
oneText.setText(text.substring(i, i+1));
if(size>0)
{
oneText.setTextSize(size);
}
addView(oneText);
}
}
}
public void setTextColor(int color)
{
this.color=color;
}
public void setTextSize(int size)
{
this.size=size;
}
}
你也可以修改里边的字体大小的。最好字数不要多,这样的空间字数多了消耗比较的大。
在xml当中加入包名,这个应该知道吧。
⑸ 编程。 安卓编程,点击按钮textview显示文本文字,代码怎么写
这太简单了,在activity中声明一个
Button ib_01;
Textview tv_01;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ib_01 = (Button)this.findViewById(R.id.这里写你按钮的ID);
tv_01 = (Textview)this.findViewById(R.id.这里写你textview的ID);
ib_01.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
tv_01.settext("这里写你想显示在textview上的字符串");
}
})
如果楼主还是不明白可以找我QQ:959699751
⑹ 安卓蓝牙发送汉字给单片机,并且在LCD液晶屏显示汉字!!!
看看ISSC(创捷)的蓝牙模块数据BM77,ISSC公司已经被Microchip公司收购。BM77的数据手册在下面链接:
http://ww1.microchip.com/downloads/en/DeviceDoc/BM77%20Data%20Sheet%20v2.0r.pdf
安卓手机上运行一个APP,用SPP方式把数据发给BM77,BM77和单片机连接就是串口。其他LCD屏上显示汉字就不用说了吧。没有自己的APP也可以直接用ISSC提供的“BTCHAT” APP。
⑺ 怎样设置安卓系统手机上的字体啊
1、首先我们进入设置,如图所示。
⑻ android 怎么点击图片显示文字说明,再点击消失了
添加图片点击事件,在点击之后实现布局上的文字的显示和消失,这个布局可以用frameLayout来实现,将上层的文字啥的先不显示就行了
⑼ 怎么让手机全屏显字
以iphone8为例,步骤如下:
1、打开主屏幕,找到“设置”,进入到设置列表界面。
⑽ 手机字体怎么设置
您好,手机字体大小设置方法不同手机具体的设置方法有所区别,但大都大同小异,以小米手机为例介绍手机字体大小调整方法,具体如下:
1、打开手机的设置,下滑找到显示选项