2012-02-27 2 views
0

Я делаю макет программным способом. Моя проблема в том, что я не могу дать ширину белой области? Как я могу это сделать. И я не могу выровнять по правой и центральной стрелке?Ширина компоновки программно?

Мой код:

 public infoline(Context context) { 
     super(context); 
     this.setBackgroundResource(R.drawable.all_line); 
     new MarginLayoutParams(MarginLayoutParams.FILL_PARENT, MarginLayoutParams.FILL_PARENT); 

     areaPic=new ImageView(getContext()); 
     areaPic.setBackgroundResource(R.drawable.profil_photo); 


     mainLayout=new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); 
     mainLayout.setMargins(10,10,10,10); 
     addView(areaPic, mainLayout); 

     next=new ImageView(getContext()); 
     next.setBackgroundResource(R.drawable.ok_12_22dip); 

     LinearLayout.LayoutParams nextlayout =new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT); 
     nextlayout.gravity = Gravity.RIGHT; 
     nextlayout.topMargin=10; 
     addView(next,nextlayout); 

} 

XML:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="360dip" 
       android:layout_height="480dip"> 
    <ScrollView 
     android:layout_height="250dip" 
     android:layout_width="360dip" 
     android:id="@+id/scrolline_search"> 
     <LinearLayout android:layout_height="wrap_content" 
         android:layout_width="200dip" 
         android:id="@+id/addline_search"> 

     </LinearLayout> 

     </ScrollView> 

</LinearLayout> 

ответ

0

использовать это, это поможет вам

LinearLayout.LayoutParams addQuestion_Params = 
new LinearLayout.LayoutParams(100, 100); 

здесь 100 ширина и высота кнопки.

Смежные вопросы