ImageButton in an HorizontalSrollView have a frame
I have this Layout:
<HorizontalScrollView android:id="@+id/card_images_horizontalscroll"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scrollbars="none"
android:visibility="invisible"
>
<LinearLayout android:id="@+id/card_images_layout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageButton
android:id="@+id/card_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icona"
android:
/>
</LinearLayout>
</HorizontalScrollView>
But I meet this issues: the image are enclose by a frame which I don't want, what's wrong?!
Like this:
Thanks so much!
I tried to change XML with this runtime code but I have the same issues:
b = new ImageButton(this);
开发者_运维知识库 b.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
b.startAnimation(alpha_animation);
b.setImageBitmap(myBitmap);
I tried also to follow the suggestion for change ImageButton in Button, but can I set at runtime the image source?
You can add the image to the ImageButton with:
android:src="@drawable/icona"
and then set the background to null like this:
android:background="@null"
Replace your ImageButton
with a Button
with the background you want:
<Button
android:id="@+id/card_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icona"/>
精彩评论