在我的应用程序中,我有一个标题(TextView)和一个图像。图片是从网上抓取的,大部分图片大小不一。其中一些图像太高并重叠在我的 TextView 顶部,将其覆盖。有什么办法可以防止这种情况发生吗?
<?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>
最佳答案
我认为问题出在 android:layout_height="fill_parent"因为你已经创建了高度与父 View 匹配的 imageview,所以请将它设为 "wrap_content"而不是 "fill_parent"。
编辑: 如果您想要以像素为单位的显示尺寸,您可以使用
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
关于android - 如何防止 Android ImageView 与 TextView 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3782038/