導航:首頁 > 軟體知識 > 安卓開發程序怎麼換行

安卓開發程序怎麼換行

發布時間:2022-12-25 20:56:28

⑴ Android studio 自動換行

我用的是apicloud studio,換行在窗口--首選項--Aptana Studio--Edictors--Enable word wrap。勾選了之後重啟軟體

⑵ android 中組件怎麼換行

應用中獲取會用到需要自動換行的控制項,而這並不是一般的線性或者相對布局就能實現的,在此分享下自定義控制項。原型是在網上找到的,在此稍作了修改。
這是設計出的樣稿,樣稿中的較高的圖片是從一個數據集中的穿插在另一個數據集中的,Textview的長度需要根據文字的長度不同而設置,而左右需要平分,做法如下:

1.將總體分為兩個數據集:左&右,並用2個LinearLayout分別裝自定義控制項

android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip">

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

android:layout_width="fill_parent"
android:layout_height="wrap_content">
</<span style="line-height: 21px;">PredicateLayout>

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<<span style="line-height: 21px;">PredicateLayout android:id="@+id/righttab"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</<span style="line-height: 21px;">PredicateLayout>

2.自定義控制項
public class PredicateLayout extends LinearLayout {
int mLeft, mRight, mTop, mBottom;
Hashtable map = new Hashtable();
public PredicateLayout(Context context) {
super(context);
}
public PredicateLayout(Context context, int horizontalSpacing, int verticalSpacing) {
super(context);
}
public PredicateLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int mWidth = MeasureSpec.getSize(widthMeasureSpec);
int mCount = getChildCount();
int mX = 0;
int mY = 0;
mLeft = 0;
mRight = 0;
mTop = 5;
mBottom = 0;
int j = 0;
View lastview = null;
for (int i = 0; i < mCount; i++) {
final View child = getChildAt(i);

child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
// 此處增加onlayout中的換行判斷,用於計算所需的高度
int childw = child.getMeasuredWidth();
int childh = child.getMeasuredHeight();
mX += childw; //將每次子控制項寬度進行統計疊加,如果大於設定的高度則需要換行,高度即Top坐標也需重新設置
Position position = new Position();
mLeft = getPosition(i - j, i);
mRight = mLeft + child.getMeasuredWidth();
if (mX >= mWidth) {
mX = childw;
mY += childh;
j = i;
mLeft = 0;
mRight = mLeft + child.getMeasuredWidth();
mTop = mY + 5;
//PS:如果發現高度還是有問題就得自己再細調了
}
mBottom = mTop + child.getMeasuredHeight();
mY = mTop; //每次的高度必須記錄 否則控制項會疊加到一起
position.left = mLeft;
position.top = mTop + 3;
position.right = mRight;
position.bottom = mBottom;
map.put(child, position);
}
setMeasuredDimension(mWidth, mBottom);
}
@Override
protected LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(1, 1); // default of 1px spacing
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
Position pos = map.get(child);
if (pos != null) {
child.layout(pos.left, pos.top, pos.right, pos.bottom);
} else {
Log.i("MyLayout", "error");
}
}
}
private class Position {
int left, top, right, bottom;
}
public int getPosition(int IndexInRow, int childIndex) {
if (IndexInRow > 0) {
return getPosition(IndexInRow - 1, childIndex - 1)
+ getChildAt(childIndex - 1).getMeasuredWidth() + 8;
}
return getPaddingLeft();
}
}
3.將數據分別填充到左右兩個控制項中
這應該算是自動換行經典實例了吧,相信這個搞定以後同類型的需求都不成問題了。

⑶ 安卓開發應用中text中如何自由讓文本換行,想在哪換就在哪換,詳細點哦!多謝多謝!我是菜鳥。

TextView中顯示文本,讓文本換行,第一種:設置TextView的寬和高,第二種:設置屬性maxLength來設置最多顯示字數,第三種:就是顯示的文本中想換行的位置加\n!

⑷ android textview 怎麼換行

textView如果想要強制換行的話,必須先把TextView顯示方式修改為多行(android:singleLine="false"),然後才能換行。
方法一般用兩種:

1、在字元串里加入「 」,如"abc rc";

2、把TextView設置為固定寬度,然後讓系統自動換行。如android:layout_width="100dp";

(4)安卓開發程序怎麼換行擴展閱讀

Class Overview

向用戶顯示文本,並可選擇允許他們編輯文本。TextView是一個完整的文本編輯器,但是基類為不允許編輯;其子類EditText允許文本編輯。

允許用戶復制部分或全部內容,將其粘貼到別的地方,設置XML屬性Android:textisselectable :「真」 或設置相關方法 settextisselectable 為「真」。textisselectable flag 允許用戶在TextView選擇手勢,從而觸發系統內置的復制/粘貼控制項。

Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; seeEditTextfor a subclass that configures the text view for editing.

To allow users to some or all of the TextView's value and paste it somewhere else, set the XML attributeandroid:textIsSelectableto "true" or callsetTextIsSelectable(true). ThetextIsSelectableflag allows users to make selection gestures in the TextView, which in turn triggers the system's built-in /paste controls.

⑸ 求解在安卓開發中,如何換行,/n完全無效

應該是\n,你那個斜杠反了
<TextView
android:layout_height="wrap_content"
android:text="1\n2"
android:layout_width="wrap_content"
android:textSize="20sp"/>
這樣就行了

⑹ Android文本換行問題。

根據本人測試:將數據封裝到模型類後,在Java文件中使用textViewObj.setText(obj.getXXX()).

無論是模擬器中,還是真機中,均可換行。

測試代碼:

{

/**.*/

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

TextViewtx=(TextView)findViewById(R.id.hello);

Manm=newMan();

m.setAdd("aaaaa bbbb");

m.setName("dddd cccc");

tx.setText(m.getAdd());

}

}

Man類代碼:

publicclassMan{

Stringname;

Stringadd;

publicStringgetName(){

returnname;

}

publicvoidsetName(Stringname){

this.name=name;

}

publicStringgetAdd(){

returnadd;

}

publicvoidsetAdd(Stringadd){

this.add=add;

}

}

附上一張運行圖片吧。

⑺ 安卓手機打字怎麼換行

安卓手機打字換行的方法:

1、首先打開安卓手機的主界面;

2、再打開需要輸入文字的頁面;

3、在頁面中點擊輸入框,出現輸入法以後開始打字;

4、選擇最右下角的「換行鍵」或者「回車鍵」,點擊即可換行。



文字輸入是安卓手機的一項基本操作功能,在使用安卓手機打字時,根據具體需要,可以對文字進行換行輸入,首先解鎖安卓手機的主界面,確保接下來的正常操作;在手機中打開編輯文字的軟體,點擊進入;在輸入文字界面中點擊輸入框,會出現虛擬鍵盤的相關界面;在該界面上,選擇最右下角的回車鍵圖標即可,有的輸入法會直接出現換行,點擊即可。

需要注意的是安卓手機在輸入文字的時候或在消息輸入窗口,突然沒有反應,或無法彈出輸入法鍵盤,從而無法輸入,這類情況有可能是輸入法無響應,即運行不順暢卡死,需要耐心等待或關閉後重新啟動。

⑻ 安卓軟體開發中怎麼讓一個EditText自動換行

packagecom.example.android.helloactivity;

importandroid.content.Context;

importandroid.graphics.Paint;

importandroid.graphics.Rect;

importandroid.text.TextPaint;

importandroid.util.AttributeSet;

importandroid.view.Display;

importandroid.view.KeyEvent;

importandroid.view.WindowManager;

importandroid.widget.EditText;

{

intscreenWidth=0;

intscreenHeight=0;

intcurrentHeight=0;

Contextcontext=null;

publicMyEditor(Contextcontext,AttributeSetattrs){

super(context,attrs);

this.context=context;

currentHeight=getHeight();

WindowManagerwindowManager=(WindowManager)this.context

.getSystemService(Context.WINDOW_SERVICE);

Displaydisplay=windowManager.getDefaultDisplay();

//取得屏幕寬度和高度

screenWidth=display.getWidth();

screenHeight=display.getHeight();

setScrollBarStyle(DRAWING_CACHE_QUALITY_AUTO);

/*Rectrect=newRect();

Paintp=newPaint();

p.setTypeface(getTypeface());

p.getTextBounds("A",0,1,rect);

fontWidth=rect.width();*/

}

@Override

publicbooleanonKeyUp(intkeyCode,KeyEventevent){

TextPaintpaint=getPaint();

floatlen=paint.measureText(getText().toString());

//計算得到當前應該有幾行

intline=((int)len/screenWidth+1);

getEllipsize();

setFrame(0,0,screenWidth,line*60);

//setHeight(line*60);

//setMarqueeRepeatLimit(line);

//setMaxHeight(line*60);

//setLines(line);

//setBackgroundColor(Color.WHITE);

returnfalse;

}

}

⑼ 安卓手機怎麼空格到下一行

安卓手機空格到下一行,具體操作如下。
1、首先在打開的微信程序頁面中點擊右下角的「我」選項。
2、然後在打開的「我」頁面中點擊打開「設置」選項。
3、進入「設置」頁面後點擊「聊天」選項,進入聊天設置頁面。
4、打開聊天頁面後,將「回車鍵發送消息」右側的開關按鈕關閉。
5、返回與聯系人的聊天界面中,在文字輸入框內輸入文字按下回車鍵即可換行在第二行內輸入文字了。

閱讀全文

與安卓開發程序怎麼換行相關的資料

熱點內容
發展高新技術產業需要什麼 瀏覽:23
深技術是什麼學校 瀏覽:278
電廠煙氣有哪些脫氧技術 瀏覽:129
mac系統如何強行關閉運行的程序 瀏覽:758
代理文員工作有哪些 瀏覽:711
微信小程序字轉語音怎麼操作 瀏覽:882
從池州站怎麼去池州職業技術學院 瀏覽:890
文昌海鮮市場有什麼 瀏覽:48
哪些人不能進行證券交易 瀏覽:191
機頂盒怎麼加程序 瀏覽:181
市場調研分哪些 瀏覽:622
房產中介收房子應該走什麼程序 瀏覽:208
c程序循環語句是什麼 瀏覽:177
海信電視哪個市場好 瀏覽:442
成熟的男人和程序員應該選哪個 瀏覽:587
信息量是怎麼算 瀏覽:778
大數據什麼是績效考核 瀏覽:622
旅遊優惠信息哪裡看 瀏覽:600
高速倒車多久會收到信息 瀏覽:401
杭州聯通信息中心電話是多少 瀏覽:356