How to prevent Android ImageView from Overlapping TextView
In 开发者_开发知识库my application I have a title(TextView) and an Image. The image is grabbed from the web and most of the images are different sizes. Some of these images are to tall and overlap on top of my textview, covering it up. Is there anyway to prevent this?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/screen"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<android.gesture.GestureOverlayView
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:paddingBottom="10px"
android:layout_weight="1.0"
/>
<ImageView
android:id="@+id/picview"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="10px"
android:cropToPadding="true"
android:layout_weight="0.0"
/>
</android.gesture.GestureOverlayView>
</LinearLayout>
I think problem is at android:layout_height="fill_parent" because you have created imageview whose height is matched with parent view, so pls make it "wrap_content" instead of "fill_parent".
Edit: If you want the the display dimensions in pixels you can use
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
精彩评论