TextViewEx,(Textjustify) [英] TextViewEx, (Textjustify)
问题描述
我的问题是这样的,用TextViewEx( https://github.com/bluejamesbond/TextJustify-Android )类的文本来证明我的Android应用程序运行正常,直到该文本在一个回车出现\\ N,当这种情况发生的文字显示不失去这个ASIN几行,我需要一个解决方案来证明没有HTML注入课文,更改字体大小,如果应用程序是从移动或平板电脑上打开,如果知道问题是什么,并能帮助我,我感谢你。
我会把code在我的应用程序:
code XML:
<滚动型
机器人:ID =@ + ID / scrollView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =match_parent
机器人:layout_marginLeft =25dp
机器人:layout_marginRight =25dp
机器人:layout_marginTop =45dp
机器人:layout_below =@ + ID /厂景> < RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingBottom会=50dp
机器人:背景=@绘制/ background_border> <的TextView
机器人:ID =@ + ID / txt_fecha_promociones
风格=@风格/ fechaDentroxlarge
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_marginLeft =20dp
机器人:layout_marginTop =20dp
机器人:文字=24/05/2014/> <的TextView
机器人:ID =@ + ID / txt_titulo_promociones
风格=@风格/ tituloDentroxlarge
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =20dp
机器人:layout_below =@ + ID / comparte
机器人:文字=TITULO/> **< com.xxxxx.tools.TextViewEx
机器人:ID =@ + ID / txt_noticia_promociones
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / img_promo
机器人:layout_marginLeft =30dp
机器人:layout_marginRight =30dp
机器人:layout_marginTop =20dp
机器人:TEXTSIZE =30sp
机器人:文字=noticia
机器人:文字颜色=@色/ txtBlanco/> ** < ImageView的
机器人:ID =@ + ID / comparte
机器人:layout_width =50dp
机器人:layout_height =50dp
机器人:layout_alignParentRight =真
机器人:layout_marginRight =15dp
机器人:layout_marginTop =15dp
机器人:layout_toLeftOf =@ + ID / txt_fecha_promociones
安卓的onClick =compartir
机器人:SRC =@绘制/ share_icon_white/> < ImageView的
机器人:ID =@ + ID / img_promo
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / txt_titulo_promociones
机器人:layout_marginLeft =40dp
机器人:layout_marginRight =40dp
机器人:layout_marginTop =20dp
机器人:layout_marginBottom =20dp
机器人:SRC =@绘制/促销1/> < / RelativeLayout的>
< /滚动型>
code的java:
公共类XXXXX扩展NavegacionActivity { TextView的txt_servicio;
TextViewEx txt_descripcion;
TextView的prueba;
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_servicios_dentro);
setBehindContentView(R.layout.menu); getSlidingMenu()setBehindOffset(100)。 txt_servicio =(的TextView)findViewById(R.id.txt_titulo_servicio);
txt_descripcion =(TextViewEx)findViewById(R.id.txt_descripcion_servicios); 意向I = getIntent(); txt_servicio.setText(i.getStringExtra(SERVICIO));
txt_descripcion.setText(i.getStringExtra(descripcion),TRUE); } @覆盖
公共无效onBack pressed(){
// TODO自动生成方法存根
意图I =新意图(这一点,xxxx.class);
startActivity(ⅰ);
this.finish();
}
}
刚去TextViewEx.java并改变这个code:
@覆盖
公共无效setPadding(INT离开,诠释顶部,右INT,INT底部){
DisplayMetrics指标=的getContext()。getResources()
.getDisplayMetrics();
super.setPadding((INT)((左+(metrics.density * 10))),顶,
(INT)(右+(metrics.density * 10)),
(中间体)(底部+(metrics.heightPixels * 1.5)));
Log.i(日志,指标:+指标);
}
my problem is this, using TextViewEx (https://github.com/bluejamesbond/TextJustify-Android) class texts to justify my android application works fine until the text over a carriage return appear \ n, when this happens the text is cut losing asin several lines of this, I need a solution to justify text without html injection, to change the font size if the application is open from mobile or from a tablet, if know what the problem is and can help me I thank you.
I will put the code in my application:
code xml:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="45dp"
android:layout_below="@+id/view1" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="50dp"
android:background="@drawable/background_border" >
<TextView
android:id="@+id/txt_fecha_promociones"
style="@style/fechaDentroxlarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="24/05/2014" />
<TextView
android:id="@+id/txt_titulo_promociones"
style="@style/tituloDentroxlarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_below="@+id/comparte"
android:text="Titulo" />
**<com.xxxxx.tools.TextViewEx
android:id="@+id/txt_noticia_promociones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_promo"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:textSize="30sp"
android:text="noticia"
android:textColor="@color/txtBlanco" />**
<ImageView
android:id="@+id/comparte"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_toLeftOf="@+id/txt_fecha_promociones"
android:onClick="compartir"
android:src="@drawable/share_icon_white" />
<ImageView
android:id="@+id/img_promo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_titulo_promociones"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:src="@drawable/promo1" />
</RelativeLayout>
</ScrollView>
code java:
public class xxxxx extends NavegacionActivity {
TextView txt_servicio;
TextViewEx txt_descripcion;
TextView prueba;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_servicios_dentro);
setBehindContentView(R.layout.menu);
getSlidingMenu().setBehindOffset(100);
txt_servicio = (TextView) findViewById(R.id.txt_titulo_servicio);
txt_descripcion = (TextViewEx) findViewById(R.id.txt_descripcion_servicios);
Intent i = getIntent();
txt_servicio.setText(i.getStringExtra("servicio"));
txt_descripcion.setText(i.getStringExtra("descripcion"),true);
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
Intent i = new Intent(this, xxxx.class);
startActivity(i);
this.finish();
}
}
Just go to TextViewEx.java and change to this code:
@Override
public void setPadding(int left, int top, int right, int bottom) {
DisplayMetrics metrics = getContext().getResources()
.getDisplayMetrics();
super.setPadding((int) ((left + (metrics.density * 10))), top,
(int) (right + (metrics.density * 10)),
(int) (bottom + (metrics.heightPixels * 1.5)));
Log.i("Log", "metrics : " + metrics);
}
这篇关于TextViewEx,(Textjustify)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!