Это мой код xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<Button
android:id="@+id/button_weather9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Πίσω" />
<ImageView
android:id="@+id/weather_icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:scaleType="fitXY"
android:src="@drawable/weather1" />
</LinearLayout>
Но в моем приложении я хочу, чтобы внутри моего класса динамически устанавливался новый xml с теми же вещами, что и выше. Я не знаю, какие именно будут параметры. До сих пор я написал это. Можете ли вы помочь мне с этим и завершить то, что отсутствует:
final LinearLayout test2 = new LinearLayout(this);
test2.setOrientation(LinearLayout.VERTICAL);
test2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
final Button Back = new Button(this);
Back.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Back.setText("Back");
test2.addView(Back);
final LoaderImageView image = new LoaderImageView(this, ImageUrl);
image.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
Меня больше интересует ScaleType, потому что image.ScaleType(FILL)
не работает.