1
I’m using this code to create a Imageview and add it to a Linearlayout:
public void inserindoImage(ImageView image,int rid,LinearLayout linear )
{
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
image.setLayoutParams(params);
image.setImageResource(rid);
linear.addView(image);
}
Only that LinearLayout
did not accompany the imageView
and there was a space above and below the image.
follow the screenshots of the screen
xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.teste.teste1.Principal"
android:background="#FFEC0D0D">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:id="@+id/scrollView">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearImage"
android:orientation="horizontal">
<!--Imagem vem aqui-->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearImage2"
android:orientation="horizontal">
<!--Imagem vem aqui-->
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
How can I eliminate that space?
It is necessary to have these Linearlayout all? Can’t just be one and put there the images all?
– ramaral
@ramaral yes because sometimes I play text there
– Vale