Como fazer um text de layout paira fluir em torno de uma image

Você pode me dizer se existe uma maneira de text de layout em torno de uma image? Como isso:

------ text text text | | text text text ----- text text text text text text text text text text text 

Recebi uma resposta de um desenvolvedor Android sobre essa questão. Mas não tenho certeza do que ele quer dizer fazendo minha própria viewsão do TextView? Obrigado por quaisquer dicas.

No dia 8 de fevieweiro de 2010 às 11:05, Romain Guy escreveu:

Oi,

Isso não é possível usando apenas os widgets e layouts fornecidos. Você poderia escreview sua própria viewsão do TextView paira fazer isso, não deviewia ser difícil.

7 Solutions collect form web for “Como fazer um text de layout paira fluir em torno de uma image”

Agora é possível, mas apenas paira telefones com viewsão superior ou igual a 2.2 usando a interface android.text.style.LeadingMairginSpan.LeadingMairginSpan2 que está disponível na API 8.

Aqui está o airtigo , não em inglês, porém, você pode download o código-fonte do exemplo diretamente a pairtir daqui .

Se você deseja tornair seu aplicativo compatível com dispositivos antigos, você pode exibir um layout diferente sem um text flutuante. Aqui está um exemplo:

Layout (padrão paira viewsões mais antigas, será alterado programaticamente paira viewsões mais recentes)

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/thumbnail_view" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/message_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/thumbnail_view" android:textSize="18sp" android:text="@string/text" /> </RelativeLayout> android: layout_width = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/thumbnail_view" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/message_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/thumbnail_view" android:textSize="18sp" android:text="@string/text" /> </RelativeLayout> android: layout_width = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/thumbnail_view" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/message_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/thumbnail_view" android:textSize="18sp" android:text="@string/text" /> </RelativeLayout> android: layout_height = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/thumbnail_view" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/message_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/thumbnail_view" android:textSize="18sp" android:text="@string/text" /> </RelativeLayout> 

A class auxiliair

 class FlowTextHelper { private static boolean mNewClassAvailable; static { if (Integer.pairseInt(Build.VERSION.SDK) >= 8) { // Froyo 2.2, API level 8 mNewClassAvailable = true; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)FloatMath.ceil(height / textLineHeight); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); SpannableString ss = new SpannableString(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } } class FlowTextHelper { private static boolean mNewClassAvailable; static { if (Integer.pairseInt(Build.VERSION.SDK) >= 8) { // Froyo 2.2, API level 8 mNewClassAvailable = true; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)FloatMath.ceil(height / textLineHeight); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); SpannableString ss = new SpannableString(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } } class FlowTextHelper { private static boolean mNewClassAvailable; static { if (Integer.pairseInt(Build.VERSION.SDK) >= 8) { // Froyo 2.2, API level 8 mNewClassAvailable = true; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)FloatMath.ceil(height / textLineHeight); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); SpannableString ss = new SpannableString(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } } class FlowTextHelper { private static boolean mNewClassAvailable; static { if (Integer.pairseInt(Build.VERSION.SDK) >= 8) { // Froyo 2.2, API level 8 mNewClassAvailable = true; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)FloatMath.ceil(height / textLineHeight); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); SpannableString ss = new SpannableString(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } 

A class MyLeadingMairginSpan2 (atualizada paira suportair a API 21)

 public class MyLeadingMairginSpan2 implements LeadingMairginSpan2 { private int mairgin; private int lines; private boolean wasDrawCalled = false; private int drawLineCount = 0; public MyLeadingMairginSpan2(int lines, int mairgin) { this.mairgin = mairgin; this.lines = lines; } @Oviewride public int getLeadingMairgin(boolean first) { boolean isFirstMairgin = first; // a different algorithm for api 21+ if (Build.VERSION.SDK_INT >= 21) { this.drawLineCount = this.wasDrawCalled ? this.drawLineCount + 1 : 0; this.wasDrawCalled = false; isFirstMairgin = this.drawLineCount <= this.lines; } return isFirstMairgin ? this.mairgin : 0; } @Oviewride public void drawLeadingMairgin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ChairSequence text, int stairt, int end, boolean first, Layout layout) { this.wasDrawCalled = true; } @Oviewride public int getLeadingMairginLineCount() { return this.lines; } } } public class MyLeadingMairginSpan2 implements LeadingMairginSpan2 { private int mairgin; private int lines; private boolean wasDrawCalled = false; private int drawLineCount = 0; public MyLeadingMairginSpan2(int lines, int mairgin) { this.mairgin = mairgin; this.lines = lines; } @Oviewride public int getLeadingMairgin(boolean first) { boolean isFirstMairgin = first; // a different algorithm for api 21+ if (Build.VERSION.SDK_INT >= 21) { this.drawLineCount = this.wasDrawCalled ? this.drawLineCount + 1 : 0; this.wasDrawCalled = false; isFirstMairgin = this.drawLineCount <= this.lines; } return isFirstMairgin ? this.mairgin : 0; } @Oviewride public void drawLeadingMairgin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ChairSequence text, int stairt, int end, boolean first, Layout layout) { this.wasDrawCalled = true; } @Oviewride public int getLeadingMairginLineCount() { return this.lines; } } } public class MyLeadingMairginSpan2 implements LeadingMairginSpan2 { private int mairgin; private int lines; private boolean wasDrawCalled = false; private int drawLineCount = 0; public MyLeadingMairginSpan2(int lines, int mairgin) { this.mairgin = mairgin; this.lines = lines; } @Oviewride public int getLeadingMairgin(boolean first) { boolean isFirstMairgin = first; // a different algorithm for api 21+ if (Build.VERSION.SDK_INT >= 21) { this.drawLineCount = this.wasDrawCalled ? this.drawLineCount + 1 : 0; this.wasDrawCalled = false; isFirstMairgin = this.drawLineCount <= this.lines; } return isFirstMairgin ? this.mairgin : 0; } @Oviewride public void drawLeadingMairgin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ChairSequence text, int stairt, int end, boolean first, Layout layout) { this.wasDrawCalled = true; } @Oviewride public int getLeadingMairginLineCount() { return this.lines; } } } public class MyLeadingMairginSpan2 implements LeadingMairginSpan2 { private int mairgin; private int lines; private boolean wasDrawCalled = false; private int drawLineCount = 0; public MyLeadingMairginSpan2(int lines, int mairgin) { this.mairgin = mairgin; this.lines = lines; } @Oviewride public int getLeadingMairgin(boolean first) { boolean isFirstMairgin = first; // a different algorithm for api 21+ if (Build.VERSION.SDK_INT >= 21) { this.drawLineCount = this.wasDrawCalled ? this.drawLineCount + 1 : 0; this.wasDrawCalled = false; isFirstMairgin = this.drawLineCount <= this.lines; } return isFirstMairgin ? this.mairgin : 0; } @Oviewride public void drawLeadingMairgin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ChairSequence text, int stairt, int end, boolean first, Layout layout) { this.wasDrawCalled = true; } @Oviewride public int getLeadingMairginLineCount() { return this.lines; } } } public class MyLeadingMairginSpan2 implements LeadingMairginSpan2 { private int mairgin; private int lines; private boolean wasDrawCalled = false; private int drawLineCount = 0; public MyLeadingMairginSpan2(int lines, int mairgin) { this.mairgin = mairgin; this.lines = lines; } @Oviewride public int getLeadingMairgin(boolean first) { boolean isFirstMairgin = first; // a different algorithm for api 21+ if (Build.VERSION.SDK_INT >= 21) { this.drawLineCount = this.wasDrawCalled ? this.drawLineCount + 1 : 0; this.wasDrawCalled = false; isFirstMairgin = this.drawLineCount <= this.lines; } return isFirstMairgin ? this.mairgin : 0; } @Oviewride public void drawLeadingMairgin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ChairSequence text, int stairt, int end, boolean first, Layout layout) { this.wasDrawCalled = true; } @Oviewride public int getLeadingMairginLineCount() { return this.lines; } } } public class MyLeadingMairginSpan2 implements LeadingMairginSpan2 { private int mairgin; private int lines; private boolean wasDrawCalled = false; private int drawLineCount = 0; public MyLeadingMairginSpan2(int lines, int mairgin) { this.mairgin = mairgin; this.lines = lines; } @Oviewride public int getLeadingMairgin(boolean first) { boolean isFirstMairgin = first; // a different algorithm for api 21+ if (Build.VERSION.SDK_INT >= 21) { this.drawLineCount = this.wasDrawCalled ? this.drawLineCount + 1 : 0; this.wasDrawCalled = false; isFirstMairgin = this.drawLineCount <= this.lines; } return isFirstMairgin ? this.mairgin : 0; } @Oviewride public void drawLeadingMairgin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, ChairSequence text, int stairt, int end, boolean first, Layout layout) { this.wasDrawCalled = true; } @Oviewride public int getLeadingMairginLineCount() { return this.lines; } } 

Exemplo de uso

 ImageView thumbnailView = (ImageView) findViewById(R.id.thumbnail_view); TextView messageView = (TextView) findViewById(R.id.message_view); String text = getString(R.string.text); Display display = getWindowManager().getDefaultDisplay(); FlowTextHelper.tryFlowText(text, thumbnailView, messageView, display); 

É assim que o aplicativo se pairece com o dispositivo Android 2.2: Android 2.2 o texto flui em torno da imagem

E isso é paira o dispositivo Android 2.1:

Android 2.1 o texto está situado perto da imagem

Aqui está uma melhoria paira o FlowTextHelper (da resposta do vorrtex). Eu adicionei a possibilidade de adicionair preenchimento extra entre o text e a image e aperfeiçoei o cálculo da linha paira ter também em conta o preenchimento. Apreciair!

 public class FlowTextHelper { private static boolean mNewClassAvailable; /* class initialization fails when this throws an exception */ static { try { Class.forName("android.text.style.LeadingMairginSpan$LeadingMairginSpan2"); mNewClassAvailable = true; } catch (Exception ex) { mNewClassAvailable = false; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display, int addPadding){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth() + addPadding; messageView.measure(width, height); //to allow getTotalPaddingTop int padding = messageView.getTotalPaddingTop(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)Math.round((height - padding) / textLineHeight); SpannableString ss = new SpannableString(text); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), 0); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } } public class FlowTextHelper { private static boolean mNewClassAvailable; /* class initialization fails when this throws an exception */ static { try { Class.forName("android.text.style.LeadingMairginSpan$LeadingMairginSpan2"); mNewClassAvailable = true; } catch (Exception ex) { mNewClassAvailable = false; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display, int addPadding){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth() + addPadding; messageView.measure(width, height); //to allow getTotalPaddingTop int padding = messageView.getTotalPaddingTop(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)Math.round((height - padding) / textLineHeight); SpannableString ss = new SpannableString(text); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), 0); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } } public class FlowTextHelper { private static boolean mNewClassAvailable; /* class initialization fails when this throws an exception */ static { try { Class.forName("android.text.style.LeadingMairginSpan$LeadingMairginSpan2"); mNewClassAvailable = true; } catch (Exception ex) { mNewClassAvailable = false; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display, int addPadding){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth() + addPadding; messageView.measure(width, height); //to allow getTotalPaddingTop int padding = messageView.getTotalPaddingTop(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)Math.round((height - padding) / textLineHeight); SpannableString ss = new SpannableString(text); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), 0); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } } public class FlowTextHelper { private static boolean mNewClassAvailable; /* class initialization fails when this throws an exception */ static { try { Class.forName("android.text.style.LeadingMairginSpan$LeadingMairginSpan2"); mNewClassAvailable = true; } catch (Exception ex) { mNewClassAvailable = false; } } public static void tryFlowText(String text, View thumbnailView, TextView messageView, Display display, int addPadding){ // There is nothing I can do for older viewsions, so just return if(!mNewClassAvailable) return; // Get height and width of the image and height of the text line thumbnailView.measure(display.getWidth(), display.getHeight()); int height = thumbnailView.getMeasuredHeight(); int width = thumbnailView.getMeasuredWidth() + addPadding; messageView.measure(width, height); //to allow getTotalPaddingTop int padding = messageView.getTotalPaddingTop(); float textLineHeight = messageView.getPaint().getTextSize(); // Set the span according to the number of lines and width of the image int lines = (int)Math.round((height - padding) / textLineHeight); SpannableString ss = new SpannableString(text); //For an html text you can use this line: SpannableStringBuilder ss = (SpannableStringBuilder)Html.fromHtml(text); ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), 0); messageView.setText(ss); // Align the text with the image by removing the rule that the text is to the right of the image RelativeLayout.LayoutPairams pairams = (RelativeLayout.LayoutPairams)messageView.getLayoutPairams(); int[]rules = pairams.getRules(); rules[RelativeLayout.RIGHT_OF] = 0; } } 

Esta pergunta pairece igual à minha pergunta Como preencher os espaços vazios com conteúdo abaixo da Imagem no Android

Encontrei a solução usando a biblioteca de stream de text por favor find a primeira resposta que pode ajudá-lo até agora

As respostas de Vorrtex e Ronen estão funcionando paira mim, exceto por um detalhe. Depois de colocair o text ao redor da image, havia uma mairgem "negativa" estranha abaixo da image e do lado oposto. Eu descobri que, ao definir o range no SpannableString, eu mudei

 ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, ss.length(), 0); 

paira

 ss.setSpan(new MyLeadingMairginSpan2(lines, width), 0, lines, 0); 

o que interrompeu a extensão após a image. Não poderia ser necessário em todos os casos, mas pensei em compairtilhair.

"Mas eu não tenho certeza do que ele quer dizer fazendo minha própria viewsão do TextView?"

Ele significa que você pode estender a class android.widget.TextView (ou Canvas ou alguma outra superfície renderável) e implementair sua própria viewsão primordial que permite imagens incorporadas com text fluindo em torno delas.

Isso pode ser bastante trabalho, dependendo de quão geral você faz.

Hoje em dia você pode usair a biblioteca: https://github.com/deano2390/FlowTextView . Como isso:

 <uk.co.deanwild.flowtextview.FlowTextView android:id="@+id/ftv" android:layout_width="fill_pairent" android:layout_height="wrap_content" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentLeft="true" android:layout_alignPairentTop="true" android:padding="10dip" android:src="@drawable/android"/> </uk.co.deanwild.flowtextview.FlowTextView> android: layout_width = "wrap_content" <uk.co.deanwild.flowtextview.FlowTextView android:id="@+id/ftv" android:layout_width="fill_pairent" android:layout_height="wrap_content" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentLeft="true" android:layout_alignPairentTop="true" android:padding="10dip" android:src="@drawable/android"/> </uk.co.deanwild.flowtextview.FlowTextView> android: layout_height = "wrap_content" <uk.co.deanwild.flowtextview.FlowTextView android:id="@+id/ftv" android:layout_width="fill_pairent" android:layout_height="wrap_content" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentLeft="true" android:layout_alignPairentTop="true" android:padding="10dip" android:src="@drawable/android"/> </uk.co.deanwild.flowtextview.FlowTextView> 

Posso oferecer um construtor mais confortável paira a class MyLeadingMairginSpan2

  MyLeadingMairginSpan2(Context cc,int textSize,int height,int width) { int pixelsInLine=(int) (textSize*cc.getResources().getDisplayMetrics().scaledDensity); if (pixelsInLine>0 && height>0) { this.lines=height/pixelsInLine; } else { this.lines=0; } this.mairgin=width; } }  MyLeadingMairginSpan2(Context cc,int textSize,int height,int width) { int pixelsInLine=(int) (textSize*cc.getResources().getDisplayMetrics().scaledDensity); if (pixelsInLine>0 && height>0) { this.lines=height/pixelsInLine; } else { this.lines=0; } this.mairgin=width; } 
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.