Хочу создать следующую конструкцию: в LinearLayout RelativeLayout, в котором ImageView, а справа от ImageView TextView. Это должно создаваться динамически, код:
LinearLayout.LayoutParams LinParams = new LinearLayout.LayoutParams(mathcParent,wrapContent);
RelativeLayout lineLayout = new RelativeLayout(this);
lineLayout.setBackgroundColor(Color.parseColor("#D50000"));
llMain.addView(lineLayout,LinParams);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(wrapContent,wrapContent);
ImageView img = new ImageView(this);
img.setImageResource(R.mipmap.omck);
lineLayout.addView(img,params);
RelativeLayout.LayoutParams editParam = new RelativeLayout.LayoutParams(wrapContent,wrapContent);
editParam.addRule(RelativeLayout.RIGHT_OF, img.getId());
editParam.leftMargin = 10;
TextView edt = new TextView(this);
edt.setTextSize(22);
edt.setText(etName.getText().toString());
edt.setOnClickListener(onCl);
lineLayout.addView(edt, editParam);
Но в этом случае текст смещается к левой стороне RelativeLayout, накладываясь на ImageView. Если я использую верстку:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<Button android:id="@+id/btnCreate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Create"></Button>
<Button android:id="@+id/btnClear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Clear"></Button>
<EditText android:id="@+id/etName" android:layout_width="match_parent" android:layout_height="wrap_content" />
</LinearLayout>
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scroll">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/llMain" android:orientation="vertical">
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#D0F0F5">
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/omck" android:id="@+id/imgOmck" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text" android:text="Nice text" android:textSize="26dp" android:layout_toRightOf="@id/imgOmck" />
<RatingBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/imgOmck" android:layout_below="@id/text" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Все работает, как и задумано. Но нужно создавать динамически. Помогите, пожалуйста, найти ошибку.
От сервера приходит картинка, на которую накладывается TextViewВот если картинка белая TextView должен быть черным, и наоборот
Найти звезду, сумма ядерных температур планет которой наибольшаяSql запрос будет выглядеть так:
Добрый деньПри попытке дебага теста в Eclipse (Debug as -> JUnit Test) вылетает ошибка: