android文字顯示
❶ android中textview顯示文字比如: 標題:XXXX 後面的XXXX怎麼獲取
TextView是最常用的組件之一用於顯示文本
像這種需求通常是兩個TextView組成的解決方案
用兩個TextView 一個作為標題,一個作為動態內容
還是用一個TexeView 直接getText().toString() 得到文本再調用String的api split(":") 拆分,即通過:進行拆分
通常在android中都是用兩個TextVew來處理的,前面一個TextVew作為標題,是固定不變的,後面一個TextVew作為變數,動態顯示內容
獲取textView文本的api :
String txt = textView.getText().toString();
❷ android開發如何讓控制項里的文字靠左顯示
讓android的控制項文字靠左顯示,需要在xml布局文件中對控制項進行設置。
在對應布局文件中,找到該控制項。
在gravity屬性中設置,android:gravity="left"
效果如圖
❸ Android能顯示全屏文字嗎
這樣設置全屏,然後在你的layout里只放一個TextView就行了,同時設置合適的TextSize
public
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
final
Window
win
=
getWindow();
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
❹ android開發如何在一個矩形框中顯示圖片和文字
如果是初學者的話,教你一個簡單的。用
<RelativeLayout
android:background="#FFFFFF"
>
<View
android:layout_width="wrap_content"
android:layout_height="2dip"
android:layout_marginRight="40dip"
android:layout_marginLeft="40dip"
android:background="#000000"/>
就是背景顏色用白色,你自己用View畫四個邊。就是矩形的圖形。顯示圖片和文字就可以直接分別用ImageView和TextView啦。
❺ 安卓手機的最頂端怎樣顯示文字,急
安卓手機最頂端顯示文字的重要方法,是通過修改「運營商」的名稱來實現的。具體實現方法如下:1、進入「設置」-「通知和狀態欄」界面,點擊「自定義運營商名稱」項進入。2、從打開的「自定義運營商名稱」界面中,輸入通知欄要想顯示的文字內容即可。
❻ 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)
❼ android編程如何顯示大量文本
TextView本身是可以顯示大量文本的,但會左右不對齊現象,另外圖文混排的時候更不適合了,建議如下
1、自定義View,顯示大量文本
2、使用webview來顯示大量文本
❽ android中怎麼將字元串顯示在textview上
1、直接寫在布局文件里,android:text="要顯示的字元串"
2、初始化要顯示字元串的textview,然後textview.settext("要顯示的字元串");
❾ android中在運行時如何動態設置TextView的顯示文本
// 代碼邏輯獲取字元串
String value="新內容";
TextView text = findViewByid(R.id.xxx);
text.setText(value); //設置新內容
❿ android界面設計控制項字體顯示不全
你Button有沒有設置特殊屬性,如果有,你去掉,你想把文字調整到一個什麼位置呢?例如android:gravity="left"這個就是設置文字在button的最左邊,你也可以加上layout_marginLeft做適當調整,如果你想讓文字橫向居中,就用這個屬性設置android:gravity="center_horizontal"
如果是組件顯示不全的話,就按照樓上所說,以真機顯示的為准