Ширина макета программно? - PullRequest
0 голосов
/ 27 февраля 2012

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

Мой код:

      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>

1 Ответ

0 голосов
/ 27 февраля 2012

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

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

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...