⑴ 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、打開手機的設置,下滑找到顯示選項