0

enter image description hereTextViews的某些部分不显示和屏幕

我从数据库中查询的结果和相应的变量被填充的边缘被切断。 我认为问题是布局,我在我的XML文件中使用不正确的布局。也许这是ArrayAdapter,我不知道。我花了很多时间试图解决这个问题,一直未能。谢谢你的帮助!

这是我的XML:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<TableRow>   
    <TextView android:id="@+id/precio_offers_charger"    
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:textStyle="bold" 
     android:textSize="20px"  
     android:textColor="#FFFFFF"   
     android:background="#FF0000" /> 

    <TextView android:id="@+id/cabecera_offers_charger" 
     android:paddingLeft="10px" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textStyle="bold" 
     android:textSize="18px" 
     android:textColor="#FFFFFF" 
     android:background="#010201" />     
</TableRow> 

<TableRow> 
    <ImageView android:id="@+id/imagen"   
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView android:id="@+id/descripcion_offers_charger" 
     android:paddingLeft="10px" 
     android:paddingTop="10px"   
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:textStyle="normal" 
     android:textSize="14px" />          
</TableRow>  

<ListView android:id="@android:id/list"   
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 
</ListView> 

</TableLayout> 

这是我的课的一部分:

public class OffersChargerActivity extends ListActivity{      

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.offers_charger); 

... 


public class AdaptadorTitulares extends ArrayAdapter<Oferta> { 

    Activity context; 

    AdaptadorTitulares(Activity context) { 
     super(context, R.layout.offers_charger, ofertas); 
     this.context = context; 
    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     View view = convertView; 
     if (view == null) { 
      LayoutInflater linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      view = linflater.inflate(R.layout.offers_charger, null); 
     }     

     // poblamos la lista de elementos   
     TextView precio = (TextView)view.findViewById(R.id.precio_offers_charger); 
     precio.setText(ofertas.get(position).getPrecio().concat("€")); 

     ImageView imagen = (ImageView) view.findViewById(R.id.imagen); 
     imagen.setImageBitmap(new GetImages().downloadFile(ofertas.get(position).getImagen())); 

     TextView cabecera = (TextView)view.findViewById(R.id.cabecera_offers_charger); 
     cabecera.setText(ofertas.get(position).getCabecera()); 

     TextView descripcion = (TextView)view.findViewById(R.id.descripcion_offers_charger); 
     descripcion.setText(ofertas.get(position).getDescripcion());             

     return view; 
    }      
} 

... 

}

回答

2

这为我工作:

<TextView 
     android:id="@+id/nameText" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center_vertical" 
     android:textColor="@android:color/black" /> 

尝试添加'layout_weight'并将您的'layout_width'更改为“fill_parent”。

希望这会有所帮助!

+0

Works !,谢谢! – JoseAntonio1984 2012-07-30 23:12:34

+0

不用担心,交配。 – edwoollard 2012-07-31 09:09:59

0

不包装内容,使用fill_parent作为宽度,并且还设置了android:ellipsize =“true”

+0

我刚才说的。 'android:ellipsize =“true”'也不需要。 – edwoollard 2012-07-30 21:02:03

+0

通过说'或者'你暗示第一部分不需要以及? – Shark 2012-07-30 21:11:31

+0

没有。我非常肯定,使'fill_parent'是修复它。因此,为什么这是我的答案... – edwoollard 2012-07-30 21:14:23

相关问题